Пример #1
0
        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());
        }
Пример #2
0
        private Shop MakeClickNCollectOrderAlreadyPaid()
        {
            var webSession = new WebSession();
            var customer   = _webAuthentificationService.ConnectCustomer(
                "*****@*****.**",
                "notfunnypassword"
                );

            webSession.ConnectCustomer(customer);

            var articleBarCode = "0102030405";
            var article        = _articlesService.GetArticles(articleBarCode).First();

            webSession.AddArticle(article);
            var availablesShops = _shopInfosService.GetShops();

            Assert.AreEqual(2, availablesShops.Count());

            var selectedShop = availablesShops.First(
                shop => shop.Address.City == "Toulouse"
                );

            webSession.SetClickNCollectDeliveryMode(selectedShop.Id);

            webSession.PayWtihBC(
                "4545-5555-5555-5555",
                "01/25",
                "111"
                );
            webSession.CompleteTransaction();

            return(webSession.GetSelectedShop());
        }
Пример #3
0
        public void REQ_15_MakeOnlineBracket_WithoutConnection()
        {
            var webSession     = new WebSession();
            var articleBarCode = "0102030405";
            var article        = _articlesService.GetArticles(articleBarCode).First();

            webSession.AddArticle(article);
            Assert.AreEqual(article.Price, webSession.Bracket.GetTotalPrice());
            Assert.IsFalse(webSession.CanFinalizeOrder);
        }
Пример #4
0
        public async Task <IActionResult> Index(
            [FromQuery] int page = 1, [FromQuery] int pageSize = 5)
        {
            var articles = await _articlesService.GetArticles(pageSize, pageSize);

            var basePath = Request.Path;

            return(StatusCodeAndDtoWrapper.BuildSuccess(ArticleListDtoResponse.Build(articles.Item2, basePath,
                                                                                     currentPage: page, pageSize: pageSize, totalItemCount: articles.Item1)));
        }
Пример #5
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());
        }
Пример #6
0
        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);
        }