Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Stryker 4.0.6, kill a few mutants #234

Merged
merged 2 commits into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
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
Loading