public void REQ_7_PayBillWithCheck() { var cashier = _authentificationService.ConnectCashier("123456"); var cashRegister = new CashRegister(cashier); var firstSelectedArticle = _articlesService.GetArticles("0102030405").First(); cashRegister.AddArticle(firstSelectedArticle); var secondSelectedArticle = _articlesService.GetArticles("0203040506").First(); cashRegister.AddArticle(secondSelectedArticle); var bracketTotalPrice = firstSelectedArticle.Price + secondSelectedArticle.Price; Assert.AreEqual(bracketTotalPrice, cashRegister.GetRemainsDependent()); cashRegister.PayWithCheck(bracketTotalPrice); Assert.IsTrue(cashRegister.CanCompleteTransaction); Assert.AreEqual(0, cashRegister.GetRemainsDependent()); Assert.AreEqual(1, cashRegister.Bracket.Transactions.Count()); var firstTransaction = cashRegister.Bracket.Transactions.ElementAt(0); Assert.AreEqual(bracketTotalPrice, firstTransaction.Amount); Assert.AreEqual(TransactionType.Check, firstTransaction.Type); cashRegister.CompleteTransaction(); Assert.IsNull(cashRegister.Bracket); Assert.IsNull(cashRegister.WebOrder); }
public void REQ_6_ResumeBracketMemento() { var cashier = _authentificationService.ConnectCashier("123456"); Assert.IsNotNull(cashier); var cashRegister = new CashRegister(cashier); var articles = _articlesService.GetArticles("0102030405"); Assert.IsTrue(articles.Count() > 0); var selectedArticle = articles.First(); cashRegister.AddArticle(selectedArticle); var bracketMemento = cashRegister.MakeBracketMemento(); _mementoService.SaveBracket(bracketMemento); Assert.IsNull(cashRegister.Bracket); var savedBracket = _mementoService.GetSavedBracket(bracketMemento.Id); Assert.AreEqual(0, _mementoService.SavedBrackets.Count()); cashRegister.RestoreBracket(savedBracket); Assert.AreEqual(1, cashRegister.Bracket.Articles.Count()); Assert.AreEqual(selectedArticle.Price, cashRegister.Bracket.GetTotalPrice()); }
public void REQ_7_PayBillWithReceiptAndBill() { var cashier = _authentificationService.ConnectCashier("123456"); var cashRegister = new CashRegister(cashier); var firstSelectedArticle = _articlesService.GetArticles("0102030405").First(); cashRegister.AddArticle(firstSelectedArticle); var secondSelectedArticle = _articlesService.GetArticles("0203040506").First(); cashRegister.AddArticle(secondSelectedArticle); var bracketTotalPrice = firstSelectedArticle.Price + secondSelectedArticle.Price; cashRegister.PayWithCash(bracketTotalPrice); Assert.IsTrue(cashRegister.CanCompleteTransaction); var receipt = cashRegister.GetReceipt(); Assert.IsTrue(receipt.Contains("Receipt")); Assert.IsTrue(receipt.Contains($"{firstSelectedArticle.Name} - 1 - {firstSelectedArticle.Price}€")); Assert.IsTrue(receipt.Contains($"{secondSelectedArticle.Name} - 1 - {secondSelectedArticle.Price}€")); Assert.IsTrue(receipt.Contains($"Cash : {bracketTotalPrice}€")); Assert.IsTrue(receipt.Contains("Change : 0€")); cashRegister.PrintReceipt(receipt); var bill = cashRegister.GetBill(); Assert.IsTrue(bill.Contains("Bill")); Assert.IsTrue(bill.Contains($"{firstSelectedArticle.Name} - 1 - {firstSelectedArticle.Price}€")); Assert.IsTrue(bill.Contains($"{secondSelectedArticle.Name} - 1 - {secondSelectedArticle.Price}€")); Assert.IsTrue(bill.Contains($"Cash : {bracketTotalPrice}€")); Assert.IsTrue(bill.Contains("Change : 0€")); cashRegister.PrintBill(bill); cashRegister.CompleteTransaction(); Assert.IsNull(cashRegister.Bracket); Assert.IsNull(cashRegister.WebOrder); }
public void REQ_6_ResumeMementoWithNoEmptyBracket() { var cashier = _authentificationService.ConnectCashier("123456"); Assert.IsNotNull(cashier); var cashRegister = new CashRegister(cashier); var selectedArticle = _articlesService.GetArticles("0102030405").First(); cashRegister.AddArticle(selectedArticle); var bracketMemento = cashRegister.MakeBracketMemento(); _mementoService.SaveBracket(bracketMemento); cashRegister.AddArticle(selectedArticle); var savedBracket = _mementoService.GetSavedBracket(bracketMemento.Id); cashRegister.RestoreBracket(savedBracket); }
public void REQ_5_ArticleWithoutBarCode_KnownArticle(string query) { var cashier = _authentificationService.ConnectCashier("123456"); var cashRegister = new CashRegister(cashier); var articles = _articlesService.Search(query); Assert.IsTrue(articles.Count() > 0); var selectedArticle = articles.First(); cashRegister.AddArticle(selectedArticle); Assert.AreEqual(selectedArticle.Price, cashRegister.Bracket.GetTotalPrice()); }