Considering :
public class ListDeleter
{
public void DoingMyThing(IList<int> theList, int iNeedToBeRemoved)
{
theList.Remove(iNeedToBeRemoved);
}
}
We define the following Spec :
public class ListDeleterSpecs : ListDeleterFixture
{
[Spec]
public void List_Does_Not_Contain_Removed_Value()
{
Ensure.False(list.Contains(toRemove));
}
}
And implement a QuickDotNetCheck Fixture :
public class ListDeleterFixture : Fixture
{
private readonly ListDeleter listDeleter = new ListDeleter();
private readonly IntGenerator intGen = new IntGenerator(1, 20);
protected IList<int> list;
protected int toRemove;
public override void Arrange()
{
toRemove = intGen.GetRandomValue();
list =
new GeneratorRepository()
.With<int>(intGen)
.Randoms<int>(1, 100)
.ToList();
}
protected override void Act()
{
listDeleter.DoingMyThing(list, toRemove);
}
[Fact]
public void VerifyAll() // Assert is already spoken for by BaseFixture
{
new Suite(1, 1000)
.Register(() => new ListDeleterFixture())
.Run();
}
}
Resulting in something like :
Falsifiable after 1 test(s), 375 Transition(s).
ListDeleterSpecs.List_Does_Not_Contain_Removed_Value failed.
--------------------Simplest Fail Case--------------------
ListDeleterFixture
theInt : System.Int32 : 52
theList: List Of System.Int32 :
52
52