Given this simple class, we can test that the ShaveHead method is working correctly by asserting state of the HairLength variable is set to zero after the ShaveHead method is called.
public class Person
{
public string Name;
public int HairLength;
public Person(string name, int hairLength)
{
this.Name = name;
this.HairLength = hairLength;
}
public void ShaveHead()
{
this.HairLength = 0;
}
}
[Test]
public void Person_ShaveHead_SetsHairLengthToZero()
{
Person personUnderTest = new Person("Danny", 10);
personUnderTest.ShaveHead();
int hairLength = personUnderTest.HairLength;
Assert.AreEqual(0, hairLength);
}