[Test]
public void testMultiplication()
{
var five=new Dollar(5);
Assert.AreEqual(new Dollar(10), five.times(2));
Assert.AreEqual(new Dollar(15), five.times(3));
}
Долларовый класс
public class Dollar
{
private int amount;
public Dollar(int amount)
{
this.amount = amount;
}
public Dollar times(int multiplier)
{
return new Dollar(amount * multiplier);
}
public bool equals(Object theObject)
{
Dollar dollar = (Dollar) theObject;
return amount == dollar.amount;
}
}
On line Assert.AreEqual (новый доллар (10), пять (2)); ошибка теста с ошибкой:
Ожидаемые: TDDbooks.Dollar
Но было: TDDbooks.Dollar