public void REQ_6_MakeBracketAsMemento()
        {
            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);
            var savedBracket = _mementoService.GetSavedBracket(bracketMemento.Id);

            Assert.AreEqual(0, _mementoService.SavedBrackets.Count());
            Assert.AreEqual(1, savedBracket.Articles.Count());
            Assert.AreEqual(selectedArticle.Price, savedBracket.GetTotalPrice());
        }
Exemple #2
0
        public void REQ_4_ScanArticle_KnownArticle(string barCode)
        {
            var cashier      = _authentificationService.ConnectCashier("123456");
            var cashRegister = new CashRegister(cashier);

            var articles = _articlesService.GetArticles(barCode);

            Assert.IsTrue(articles.Count() > 0);

            var selectedArticle = articles.First();

            cashRegister.AddArticle(selectedArticle);

            Assert.AreEqual(selectedArticle.Price, cashRegister.Bracket.GetTotalPrice());
        }
        public void REQ_3_DisconnectCashier_RigthMatricule_LoggedEmployee()
        {
            var cashier = _authentificationService.ConnectCashier("123456");

            Assert.IsNotNull(cashier);

            _authentificationService.DisconnectEmployee(cashier.Login);
        }
Exemple #4
0
        public void REQ_18_ReceiptClickNCollectOrder_InToulouseShop_AlreadyPaid()
        {
            // This method return the shop used from the web part
            // In the future the Shop must be itself initilazed with DB data loading mechanism
            // In fact, for the exercise, this last element is ignored
            var shop = MakeClickNCollectOrderAlreadyPaid();

            Thread.Sleep(1000); // Some time later

            var webOrder = shop.ClickNCollectService.FindWebOrders("Already").First();

            var cashier      = _authentificationService.ConnectCashier("123456");
            var cashRegister = new CashRegister(cashier);

            cashRegister.ReceiptWebOrder(webOrder);
            Assert.IsTrue(cashRegister.CanCompleteTransaction);

            cashRegister.CompleteTransaction();
            Assert.IsNull(cashRegister.Bracket);
            Assert.IsNull(cashRegister.WebOrder);
        }
        public void REQ_7_PayBillWithCash()
        {
            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(50);
            Assert.IsFalse(cashRegister.CanCompleteTransaction);

            Assert.AreEqual(bracketTotalPrice - 50, cashRegister.GetRemainsDependent());
            cashRegister.GiveBackChange(40.5);

            Assert.IsTrue(cashRegister.CanCompleteTransaction);
            Assert.AreEqual(0, cashRegister.GetRemainsDependent());
            Assert.AreEqual(2, cashRegister.Bracket.Transactions.Count());

            var firstTransaction = cashRegister.Bracket.Transactions.ElementAt(0);

            Assert.AreEqual(50, firstTransaction.Amount);
            Assert.AreEqual(TransactionType.Cash, firstTransaction.Type);

            var secondTransaction = cashRegister.Bracket.Transactions.ElementAt(1);

            Assert.AreEqual(40.5, secondTransaction.Amount);
            Assert.AreEqual(TransactionType.CashChange, secondTransaction.Type);


            cashRegister.CompleteTransaction();
            Assert.IsNull(cashRegister.Bracket);
            Assert.IsNull(cashRegister.WebOrder);
        }
        public void REQ_2_ConnectCashier_RigthMatriculePassword()
        {
            var cashier = _authentificationService.ConnectCashier("123456");

            Assert.IsNotNull(cashier);
        }