For some reason, I have ignored the NUnit syntax around Assert.That up to now. I thought it was one of these experiments around a fluent interface which didn’t offer any advantages over the existing API.
I wanted to write a test that tested whether a value was as expected, but within a certain range. I had previously used Assert.Equals with the overload that takes a delta.
Here is an alternative implementation:
[Test]
public void MinValue_IsCloseToMinimum_OfAllBids()
{
var lowPrice = new Price(10, 20);
var otherPrice = new Price(11, 20);
var priceViewModel =
new PriceViewModel(new List {lowPriceTolerance, otherPriceTolerance});
//old api
Assert.AreEqual(10, Convert.ToDouble(priceViewModel.MinValue), 0.2);
// new api
Assert.That(priceViewModel.MinValue, Is.EqualTo(10).Within(0.2));
}