A very simple Given-When-Then testing library for NUnit
$ dotnet add package LoremFooBar.SimpleGwt.NUnitA very simple Given-When-Then testing library for NUnit
// CalculatorTests/When_Adding_Two_Numbers.cs
public class When_Adding_Two_Numbers : SpecificationBase
{
private int _num1;
private int _num2;
private Calculator _calc;
private int _sum;
public override void Given()
{
_num1 = 7;
_num2 = 3;
}
public override void When()
{
_sum = _calc.Add(_num1, _num2);
}
[Then]
public void It_Should_Return_The_Sum_Of_The_Two_Numbers()
{
_sum.Should().Be(10);
}
}
If you follow these recommendations you can get a nice readable description of your app behavior in test explorer:
