Writes, executes, and completes unit tests for C#/.NET code using xUnit, FakeItEasy, and AwesomeAssertions. Uses a second agent to identify missing test cases. Use when asked to create .NET tests or improve test coverage.
Write comprehensive unit tests for the specified code. Follow a multi-step process with automatic identification of missing test cases.
Should() as usual)Identify test project: Find the appropriate test project by looking for *.Tests.csproj files or *Tests/ directories in the solution. Fall back to scanning for any project whose name ends in .Tests or .Test. Orient yourself to the existing project structure before adding files.
Create tests: Write tests following this pattern:
public class MyClassTests
{
[Fact]
public void MethodName_Scenario_ExpectedBehavior()
{
// Arrange
var dependency = A.Fake<IDependency>();
A.CallTo(() => dependency.DoSomething()).Returns(expectedValue);
var sut = new MyClass(dependency);
// Act
var result = sut.MethodUnderTest(input);
// Assert
result.Should().Be(expectedValue);
}
[Theory]
[InlineData("input1", "expected1")]
[InlineData("input2", "expected2")]
public void MethodName_WithVariousInputs_ReturnsExpected(string input, string expected)
{
// Arrange
var sut = new MyClass();
// Act
var result = sut.MethodUnderTest(input);
// Assert
result.Should().Be(expected);
}
}
dotnet test in the relevant test projectStart a separate agent that reads the production code and written tests, then returns a prioritized list of missing cases:
Format: [HIGH/MEDIUM/LOW] MethodName - Scenario: Description
dotnet test againAt the end, provide a summary:
### Test Result
**Phase 1**: X tests written
**Phase 2**: All tests green ✅
**Phase 3**: Y missing cases identified (Z High, W Medium, V Low)
**Phase 4**: Y additional tests implemented, all green ✅
**Total**: X + Y tests, all passed
MethodName_Scenario_ExpectedBehavior[Theory] tests: Use [InlineData] for simple types, [MemberData] for complex objectsA.CallTo(...).MustHaveHappened() sparingly – only when the call is the expected behavior