-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Additional tests against missing code coverage (#25)
* Additional tests against missing code coverage * Updates logging within SyncWork to use structured logging syntax * Removes private properties from `InvalidStateException`, as their values even when made public weren't serializing correctly. This shouldn't impact the sem ver of the library, I don't think, since the properties were private anyway.
- Loading branch information
Showing
8 changed files
with
75 additions
and
67 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
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
27 changes: 27 additions & 0 deletions
27
test/Orleans.SyncWork.Tests/ExtensionMethods/SiloHostBuilderExtensionsTests.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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using FluentAssertions; | ||
using Microsoft.Extensions.Hosting; | ||
using Orleans.Hosting; | ||
using Xunit; | ||
|
||
namespace Orleans.SyncWork.Tests.ExtensionMethods; | ||
|
||
public class SiloHostBuilderExtensionsTests | ||
{ | ||
[Theory] | ||
[InlineData(4)] | ||
[InlineData(8)] | ||
public void WhenCallingConfigure_ShouldRegisterLimitedConcurrencyScheduler(int maxSyncWorkConcurrency) | ||
{ | ||
var builder = new SiloHostBuilder(); | ||
Orleans.SyncWork.ExtensionMethods.SiloHostBuilderExtensions.ConfigureSyncWorkAbstraction(builder, maxSyncWorkConcurrency); | ||
|
||
builder.UseLocalhostClustering(); | ||
|
||
var host = builder.Build(); | ||
var scheduler = (LimitedConcurrencyLevelTaskScheduler)host.Services.GetService(typeof(LimitedConcurrencyLevelTaskScheduler)); | ||
|
||
scheduler.Should().NotBeNull("the extension method was to registered the scheduler"); | ||
scheduler?.MaximumConcurrencyLevel.Should().Be(maxSyncWorkConcurrency, | ||
"the scheduler should have the registered level of maximum concurrency"); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
test/Orleans.SyncWork.Tests/LimitedConcurrencyLevelTaskSchedulerTests.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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace Orleans.SyncWork.Tests; | ||
|
||
public class LimitedConcurrencyLevelTaskSchedulerTests | ||
{ | ||
[Theory] | ||
[InlineData(1)] | ||
[InlineData(4)] | ||
public void WhenProvidedConcurrencyValueAtConstruction_ShouldContainThatLevelOfMaxConcurrency(int maxDegreeOfParallelism) | ||
{ | ||
var subject = new LimitedConcurrencyLevelTaskScheduler(maxDegreeOfParallelism); | ||
|
||
subject.MaximumConcurrencyLevel.Should().Be(maxDegreeOfParallelism); | ||
} | ||
|
||
[Theory] | ||
[InlineData(0)] | ||
[InlineData(-42)] | ||
public void WhenProvidedConcurrencyAtOrBelowZero_ShouldThrow(int maxDegreeOfParallelism) | ||
{ | ||
Action action = () => | ||
{ | ||
_ = new LimitedConcurrencyLevelTaskScheduler(maxDegreeOfParallelism); | ||
}; | ||
|
||
action.Should().Throw<ArgumentOutOfRangeException>(); | ||
} | ||
} |