public void Test_DrinkCanRepository_Reset() { using (IPaymentRepository repo = new PaymentRepository()) { //Arrange var payment1 = new Payment { PaymentID = 1, Amount = 3.50m, Type = PaymentType.Cash }; repo.Add(payment1); var payment2 = new Payment { PaymentID = 1, Amount = 1.50m, Type = PaymentType.CreditCard }; repo.Add(payment2); //Act repo.Reset(); var criteria = new PaymentFindCriteria(); var result = repo.FindByCriteria(criteria).FirstOrDefault(); repo.Delete(result); var updatedList = repo.FindByCriteria(criteria); //Assert Assert.AreEqual(0, updatedList.Count()); } }
public void Test_PaymentRepository_Find() { using (IPaymentRepository repo = new PaymentRepository()) { //Arrange var payment1 = new Payment { PaymentID = 1, Amount = 3.50m, Type = PaymentType.Cash }; repo.Add(payment1); var payment2 = new Payment { PaymentID = 1, Amount = 1.50m, Type = PaymentType.CreditCard }; repo.Add(payment2); //Act var criteria = new PaymentFindCriteria(); criteria.Type = PaymentType.CreditCard; var result = repo.FindByCriteria(criteria).FirstOrDefault(); //Assert Assert.AreEqual(payment2, result); } }
public void Test_PaymentRepository_Add() { using (IPaymentRepository repo = new PaymentRepository()) { //Arrange var payment = new Payment { PaymentID = 1, Amount = 2.50m, Type = PaymentType.Cash }; //Act repo.Add(payment); var criteria = new PaymentFindCriteria(); var count = repo.FindByCriteria(criteria).Count(); //Assert Assert.AreEqual(1, count); } }