Skip to content

Commit

Permalink
Update to Stryker 4.0.6, kill a few mutants
Browse files Browse the repository at this point in the history
  • Loading branch information
sbergen committed May 25, 2024
1 parent 8852cf7 commit c9d911a
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.user
.idea
.vs
.bin
.obj
*.received.txt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ internal void AddUntilResponder<T>(

internal void AddResponder(IBasicResponderState responder) => this.AddResponder(
responder.Description,
responder.InstructionState ?? responder,
primaryState: responder.InstructionState ?? responder,
responder.WaitState,
responder.InstructionState);

Expand Down
4 changes: 2 additions & 2 deletions src/.config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"dotnet-stryker": {
"version": "1.5.1",
"version": "4.0.6",
"commands": [
"dotnet-stryker"
]
Expand All @@ -15,4 +15,4 @@
]
}
}
}
}
16 changes: 16 additions & 0 deletions src/Responsible.Tests/StateStringTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,22 @@ public void StateString_ContainsProperlyIndentedException_WhenMultiline()
.Details(" second line");
}

[Test]
public void BlankLines_ContainASpace_ForUnity()
{
var state = Responsibly
.Do("Fail", () => throw new Exception())
.CreateState();

state.ToTask(this.Executor); // Complete task

var lines = state.ToString().Split(Environment.NewLine);

Check failure on line 39 in src/Responsible.Tests/StateStringTests.cs

View workflow job for this annotation

GitHub Actions / inspectcode

Possible 'System.NullReferenceException'
CollectionAssert.Contains(
lines,
" ",
"Blank lines should contain a space, so that Unity does not strip it");
}

[Test]
public void ExtraContext_IsIncluded_WhenProvidedAndApplicable([Values] bool run)
{
Expand Down
38 changes: 38 additions & 0 deletions src/Responsible.Tests/ThenRespondWithTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Threading.Tasks;
using NUnit.Framework;
using Responsible.Tests.Utilities;
using static Responsible.Responsibly;
// ReSharper disable AccessToModifiedClosure

Expand Down Expand Up @@ -60,6 +61,43 @@ public async Task ThenRespondWith_PropagatesErrorFromInstruction([Values] Constr
Assert.NotNull(await AwaitFailureExceptionForUnity(task));
}

[Test]
public async Task Status_IsWaiting_WhenWaitHasCompletedButInstructionNotStarted()
{
var state = ImmediateTrue
.ThenRespondWith("Responder", _ => WaitForSeconds(1))
.CreateState();

// This is lower-level than I'd want,
// but still the most direct way to start the instruction.
var instructionState = await state.ToTask(this.Executor);
_ = instructionState.ToTask(this.Executor); // Start, but don't wait

StateAssert.StringContainsInOrder(state.ToString())
.Waiting("Responder")
.Completed("True")
.Waiting("WAIT FOR");
}

[Test]
public void Status_IsWaiting_WhenWaitHasNotCompleted()
{
var state = Never
.ThenRespondWith(
"Responder",
_ => Do("Specific failure", () => throw new Exception()))
.CreateState();

state.ToTask(this.Executor); // Start execution

var stateString = state.ToString();
StateAssert.StringContainsInOrder(stateString)
.Waiting("Responder")
.Waiting("Never");

StringAssert.DoesNotContain("Specific failure", stateString);
}

private static ITestResponder<object> MakeObjectResponder<TWait>(
ConstructionStrategy strategy,
ITestWaitCondition<TWait> waitCondition)
Expand Down

0 comments on commit c9d911a

Please sign in to comment.