-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
56 changed files
with
1,218 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
src/Polly.Core.Tests/Builder/ResilienceStrategyBuilderContextTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
src/Polly.Core.Tests/Builder/ResilienceStrategyBuilderOptionsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 0 additions & 4 deletions
4
src/Polly.Core.Tests/Builder/ResilienceStrategyBuilderTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
src/Polly.Core.Tests/Builder/ResilienceStrategyOptionsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
using FluentAssertions; | ||
using Polly.Builder; | ||
using Xunit; | ||
|
||
namespace Polly.Core.Tests.Builder; | ||
|
||
|
4 changes: 0 additions & 4 deletions
4
src/Polly.Core.Tests/Builder/ResilienceStrategyPipelineTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace Polly.Core.Tests.Timeout; | ||
|
||
public class ExecutionRejectedExceptionTests | ||
{ | ||
[Fact] | ||
public void Ctor_Ok() | ||
{ | ||
new CustomException().Message.Should().Be("Exception of type 'Polly.Core.Tests.Timeout.ExecutionRejectedExceptionTests+CustomException' was thrown."); | ||
new CustomException("Dummy").Message.Should().Be("Dummy"); | ||
} | ||
|
||
private class CustomException : ExecutionRejectedException | ||
{ | ||
public CustomException() | ||
{ | ||
} | ||
|
||
public CustomException(string message) | ||
: base(message) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace Polly.Core.Tests; | ||
|
||
public class NullResilienceStrategyTests | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace Polly.Core.Tests; | ||
|
||
public class ResilienceContextTests | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 0 additions & 4 deletions
4
src/Polly.Core.Tests/ResilienceStrategyTests.Async.ValueTask.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 0 additions & 4 deletions
4
src/Polly.Core.Tests/ResilienceStrategyTests.Async.ValueTaskT.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
using FluentAssertions; | ||
|
||
namespace Polly.Core.Tests; | ||
|
||
public partial class ResilienceStrategyTests | ||
|
2 changes: 0 additions & 2 deletions
2
src/Polly.Core.Tests/Telemetry/NullResilienceTelemetryFactoryTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
using FluentAssertions; | ||
using Polly.Telemetry; | ||
using Xunit; | ||
|
||
namespace Polly.Core.Tests.Telemetry; | ||
|
||
|
3 changes: 0 additions & 3 deletions
3
src/Polly.Core.Tests/Telemetry/NullResilienceTelemetryTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
using System; | ||
using FluentAssertions; | ||
using Polly.Telemetry; | ||
using Xunit; | ||
|
||
namespace Polly.Core.Tests.Telemetry; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using Polly.Timeout; | ||
|
||
namespace Polly.Core.Tests.Timeout; | ||
|
||
public class OnTimeoutEventTests | ||
{ | ||
[Fact] | ||
public async Task Add_EnsureOrdering() | ||
{ | ||
var ev = new OnTimeoutEvent(); | ||
List<int> raisedEvents = new List<int>(); | ||
|
||
ev.Add(() => raisedEvents.Add(1)); | ||
ev.Add(args => raisedEvents.Add(2)); | ||
ev.Add(args => { raisedEvents.Add(3); return default; }); | ||
|
||
var handler = ev.CreateHandler()!; | ||
|
||
await handler(TimeoutTestUtils.OnTimeoutArguments()); | ||
|
||
raisedEvents.Should().HaveCount(3); | ||
raisedEvents.Should().BeInAscendingOrder(); | ||
} | ||
|
||
[Fact] | ||
public void Add_EnsureValidation() | ||
{ | ||
var ev = new OnTimeoutEvent(); | ||
|
||
Assert.Throws<ArgumentNullException>(() => ev.Add((Action)null!)); | ||
Assert.Throws<ArgumentNullException>(() => ev.Add((Action<OnTimeoutArguments>)null!)); | ||
Assert.Throws<ArgumentNullException>(() => ev.Add(null!)); | ||
} | ||
|
||
[InlineData(1)] | ||
[InlineData(2)] | ||
[InlineData(100)] | ||
[Theory] | ||
public async Task CreateHandler_Ok(int count) | ||
{ | ||
var ev = new OnTimeoutEvent(); | ||
var events = new List<int>(); | ||
|
||
for (int i = 0; i < count; i++) | ||
{ | ||
ev.Add(() => events.Add(i)); | ||
} | ||
|
||
await ev.CreateHandler()!(TimeoutTestUtils.OnTimeoutArguments()); | ||
|
||
events.Should().HaveCount(count); | ||
events.Should().BeInAscendingOrder(); | ||
} | ||
|
||
[Fact] | ||
public void CreateHandler_NoEvents_Null() | ||
{ | ||
var ev = new OnTimeoutEvent(); | ||
|
||
var handler = ev.CreateHandler(); | ||
|
||
handler.Should().BeNull(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using Polly.Timeout; | ||
|
||
namespace Polly.Core.Tests.Timeout; | ||
|
||
public class TimeoutAttributeTests | ||
{ | ||
[Fact] | ||
public void IsValid_Object_True() | ||
{ | ||
new TimeoutAttribute().IsValid(new object()).Should().BeTrue(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Polly.Timeout; | ||
|
||
namespace Polly.Core.Tests.Timeout; | ||
|
||
public class TimeoutConstantsTests | ||
{ | ||
[Fact] | ||
public void EnsureDefaultValues() | ||
{ | ||
TimeoutConstants.OnTimeoutEvent.Should().Be("OnTimeout"); | ||
TimeoutConstants.StrategyType.Should().Be("Timeout"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using Polly.Timeout; | ||
|
||
namespace Polly.Core.Tests.Timeout; | ||
|
||
public class TimeoutGeneratorTests | ||
{ | ||
[Fact] | ||
public void Default_EnsureCorrectValue() | ||
{ | ||
var generator = new TimeoutGenerator(); | ||
|
||
generator.CreateHandler().Should().BeNull(); | ||
} | ||
|
||
[Fact] | ||
public async Task SetTimeout_Callback_Ok() | ||
{ | ||
var generator = new TimeoutGenerator(); | ||
var delay = TimeSpan.FromSeconds(1); | ||
|
||
generator.SetTimeout(args => delay); | ||
|
||
var actualDelay = await generator.CreateHandler()!(TimeoutTestUtils.TimeoutGeneratorArguments()); | ||
|
||
actualDelay.Should().Be(delay); | ||
} | ||
|
||
[Fact] | ||
public async Task SetTimeout_AsyncCallback_Ok() | ||
{ | ||
var generator = new TimeoutGenerator(); | ||
var delay = TimeSpan.FromSeconds(1); | ||
|
||
generator.SetTimeout(args => new ValueTask<TimeSpan>(delay)); | ||
|
||
var actualDelay = await generator.CreateHandler()!(TimeoutTestUtils.TimeoutGeneratorArguments()); | ||
|
||
actualDelay.Should().Be(delay); | ||
} | ||
|
||
[Fact] | ||
public void ArgValidation_EnsureThrows() | ||
{ | ||
var generator = new TimeoutGenerator(); | ||
|
||
Assert.Throws<ArgumentNullException>(() => generator.SetTimeout((Func<TimeoutGeneratorArguments, TimeSpan>)null!)); | ||
Assert.Throws<ArgumentNullException>(() => generator.SetTimeout((Func<TimeoutGeneratorArguments, ValueTask<TimeSpan>>)null!)); | ||
} | ||
} |
Oops, something went wrong.