Pure unit tests are simple unit test cases in which “pure” functions are tested.
Pure functions are those that:
Here’s an example of a simple test of a tax calculator function:
using FluentAssertions;
using Xunit;
using static NeverendingTeaShop.Application.TeaPriceCalculator;
namespace NeverendingTeaShop.Application.Tests
{
public class TeaPriceCalculatorTest
{
[Fact]
public void CalculateTaxedPrice_GivenARetailPrice_ReturnsFullPriceWithTaxApplied()
{
CalculateTaxedPrice(19.99).Should().Be(21.74);
}
}
}
Frameworks in use to run this test are: