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:
Dev
2026-04-03 16:34:54 +02:00
parent 0122a47c9e
commit 4d7e9ea02a
4 changed files with 84 additions and 2 deletions

View File

@@ -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));
}
}