feat(05-01): make helper methods internal and add unit tests
- Changed IsThrottleException to internal static in ExecuteQueryRetryHelper - Changed BuildPagedViewXml to internal static in SharePointPaginationHelper - Created ExecuteQueryRetryHelperTests: 5 tests (throttle true x3, non-throttle false, nested false) - Created SharePointPaginationHelperTests: 5 tests (null, empty, whitespace, replace, append)
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using SharepointToolbox.Core.Helpers;
|
||||
|
||||
namespace SharepointToolbox.Tests.Helpers;
|
||||
|
||||
[Trait("Category", "Unit")]
|
||||
public class ExecuteQueryRetryHelperTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("The request has been throttled -- 429")]
|
||||
[InlineData("Service unavailable 503")]
|
||||
[InlineData("SharePoint has throttled your request")]
|
||||
public void IsThrottleException_ThrottleMessages_ReturnsTrue(string message)
|
||||
{
|
||||
var ex = new Exception(message);
|
||||
Assert.True(ExecuteQueryRetryHelper.IsThrottleException(ex));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsThrottleException_NonThrottleMessage_ReturnsFalse()
|
||||
{
|
||||
var ex = new Exception("File not found");
|
||||
Assert.False(ExecuteQueryRetryHelper.IsThrottleException(ex));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsThrottleException_NestedThrottleInInnerException_ReturnsFalse()
|
||||
{
|
||||
// Documents current behavior: only top-level Message is checked.
|
||||
// Inner exceptions with "429" are NOT currently detected.
|
||||
var ex = new Exception("outer", new Exception("429"));
|
||||
Assert.False(ExecuteQueryRetryHelper.IsThrottleException(ex));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user