- 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)
34 lines
1.1 KiB
C#
34 lines
1.1 KiB
C#
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));
|
|
}
|
|
}
|