public void TestMethod1() { IDiscount disc = new MinDiscount(); TotalValueCalculator ttcar = new TotalValueCalculator(disc); decimal truresult = books.Sum(x => x.Price); decimal realResult = ttcar.SumOfPrice(books); Assert.AreEqual(truresult, realResult, "Error value 100"); }
public void TestBymoq() { Mock <IDiscount> mock = new Mock <IDiscount>(); mock.Setup(m => m.ApplyDiscount(It.IsAny <decimal>())).Returns <decimal>(total => total); IDiscount disc = new MinDiscount(); TotalValueCalculator ttcar = new TotalValueCalculator(mock.Object); decimal truresult = books.Sum(x => x.Price); decimal realResult = ttcar.SumOfPrice(books); Assert.AreEqual(truresult, realResult, "Error value 100"); }