コード例 #1
0
ファイル: Program.cs プロジェクト: alan9259/PointOfSale
        static void Main(string[] args)
        {
            Console.WriteLine("Press q to quit");

            var quit = false;

            while (!quit)
            {
                Console.WriteLine("Enter product codes eg, AABBCC");

                var input = Console.ReadLine();

                if (input == "q")
                {
                    quit = true;
                }
                else
                {
                    var pricingRepo     = new PricingRepo();
                    var checkOutService = new CheckOutService(pricingRepo);

                    var output = checkOutService.CheckOut(input);

                    Console.WriteLine(output);
                }
            }
        }
コード例 #2
0
        private ICheckOutService CreateCheckOutService()
        {
            var pricingRepo = new PricingRepo();

            var checkOutService = new CheckOutService(pricingRepo);

            return(checkOutService);
        }
コード例 #3
0
 public CheckOutDetailsForm()
 {
     InitializeComponent();
     patronService   = PatronServiceBean.getBean();
     employeeService = EmployeeServiceBean.getBean();
     mediaService    = MediaServiceBean.getBean();
     exchangeService = ExchangeServiceBean.getBean();
     checkOutService = CheckOutServiceBean.getBean();
 }
コード例 #4
0
        public ActionResult AddressAndPaymentNoAccount(FormCollection values)
        {
            var CheckOutService = new CheckOutService();
            var CheckOut        = CheckOutService.CheckOut(this.HttpContext, values);

            if (CheckOut.Status != "Complete")
            {
                return(RedirectToAction("AddressAndPaymentNoAccount", new { model = CheckOut }));
            }
            return(RedirectToAction("Complete", new { id = CheckOut.Order.OrderId }));
        }
コード例 #5
0
        public void ValidatesPatronId()
        {
            var checkOutService = new CheckOutService(context, holdingsServiceMock.Object);
            var checkout        = new CheckOutViewModel {
                Barcode = "QA123:1", PatronId = 1
            };

            Assert.False(checkOutService.Checkout(checkout));

            Assert.Equal("Patron with ID 1 not found", checkOutService.ErrorMessages.First());
        }
コード例 #6
0
        public void ValidatesBarcode()
        {
            SavePatronWithId(context, 5);
            var checkOutService = new CheckOutService(context, holdingsServiceMock.Object);
            var checkout        = new CheckOutViewModel {
                Barcode = "QA1231", PatronId = 5
            };

            Assert.False(checkOutService.Checkout(checkout));

            Assert.Equal("Invalid holding barcode format: QA1231", checkOutService.ErrorMessages.First());
        }
コード例 #7
0
        public void ValidatesHoldingRetrieval()
        {
            SavePatronWithId(context, 5);
            var checkOutService = new CheckOutService(context, holdingsServiceMock.Object);
            var checkout        = new CheckOutViewModel {
                Barcode = "QA123:1", PatronId = 5
            };

            Assert.False(checkOutService.Checkout(checkout));

            Assert.Equal("Holding with barcode QA123:1 not found",
                         checkOutService.ErrorMessages.First());
        }
コード例 #8
0
        public async Task <ActionResult <OrderPayment> > VerifyPayment()
        {
            var checkoutPayment = new CheckOutService();
            var result          = await checkoutPayment.CaptureOrder(GetOrderId());

            Order order        = result.Result <Order>();
            var   orderPayment = new OrderPayment
            {
                OrderPaymentId = order.Id
            };

            return(Ok(orderPayment.OrderPaymentId));
        }
コード例 #9
0
        public void ValidatesHoldingAvailability()
        {
            SaveCheckedOutHoldingWithClassification(context, "QA123");
            SavePatronWithId(context, 5);
            var checkOutService = new CheckOutService(context, holdingsServiceMock.Object);
            var checkout        = new CheckOutViewModel {
                Barcode = "QA123:1", PatronId = 5
            };

            Assert.False(checkOutService.Checkout(checkout));

            Assert.Equal("Holding with barcode QA123:1 is already checked out",
                         checkOutService.ErrorMessages.First());
        }
コード例 #10
0
        public void ChecksOutMaterial()
        {
            var patron          = SavePatronWithId(context, 5);
            var holding         = SaveCheckedInHoldingWithClassification(context, "QA123");
            var checkOutService = new CheckOutService(context, holdingsServiceMock.Object);
            var checkout        = new CheckOutViewModel {
                Barcode = "QA123:1", PatronId = patron.Id
            };

            var result = checkOutService.Checkout(checkout);

            Assert.True(result);
            holdingsServiceMock.Verify(s => s.CheckOut(holding, 5));
        }
コード例 #11
0
ファイル: UnitTest1.cs プロジェクト: sabertooth13/ELMTest04
        public void TestCartCheckOutGeneralCase()
        {
            /*
             * this test uses the same product store as the above one , but this time.
             * we are picking up extra products outside of the offer.
             * for eg : when we pick 2 products for buy1get1 , then we get both of them
             * 'for the price of 1 , but insted if we take 3 , i am assuming that ,
             * two will get the offer and then the remaining one would have to be brought at its normal price.
             * the same logic would be applicable for 3for10 euro offer as well.
             * if we pick 4 , 3 will cost 10 on offer and the 4th one will have to brought at its normal price.
             *
             *
             */
            ProductService productService = new ProductService(new ProductRepository());

            productService.ApplyOfferToProducts(ProductType.A);
            productService.ApplyOfferToProducts(ProductType.B);
            productService.ApplyOfferToProducts(ProductType.c);
            Cart cart        = new Cart(new ProductRepository());
            int  cartItmQty1 = 5;

            cart.AddItem(1, cartItmQty1);
            int cartItmQty2 = 7;

            cart.AddItem(2, cartItmQty2);
            int cartItmQty3 = 5;

            cart.AddItem(3, cartItmQty3);
            CheckOutService checkOut = new CheckOutService();

            checkOut.CalcualteTotal(cart.GetTotalItemsOrdered());
            Assert.AreEqual(94, checkOut.Total);



            // this portion of code is for displaying the results
            string opHead = string.Format("Item\tQuantity\tPricet\tTotal\tPromotion");
            string opl1   = string.Format("{0}\t{1}\t${2}\t${3}\t{4}", "A", cartItmQty1, "20", checkOut.Buy1Get1Total, "Buy 1 Get 1 Free");
            string opl2   = string.Format("{0}\t{1}\t${2}\t${3}\t{4}", "B", cartItmQty2, "4", checkOut.ThreeFor10Total, "3 for 10 Euro");
            string opl3   = string.Format("{0}\t{1}\t${2}\t${3}\t{4}", "C", cartItmQty3, "2", checkOut.NoOfferTotal, "");
            string tot    = string.Format("\tTotal \t \t${0}", checkOut.Total);

            Console.WriteLine(opHead);
            Console.WriteLine(opl1);
            Console.WriteLine(opl2);
            Console.WriteLine(opl3);
            Console.WriteLine(tot);
        }
コード例 #12
0
        public async Task <ActionResult <OrderPayment> > CreatePayment(string amount, string currency)
        {
            var checkoutPayment = new CheckOutService(amount, currency);
            var result          = await checkoutPayment.CreateOrder();

            Order order        = result.Result <Order>();
            var   orderPayment = new OrderPayment
            {
                OrderPaymentId = order.Id
            };

            SaveOrderId(order.Id);
            foreach (var link in order.Links)
            {
                if (link.Rel.Equals("approve"))
                {
                    orderPayment.PayPalLink = link.Href;

                    return(Ok(orderPayment));
                }
            }
            return(NotFound());
        }
コード例 #13
0
 public CheckOutController(UserManager <ApplicationUser> userManger)
 {
     _userManager     = userManger;
     _checkOutService = new CheckOutService();
 }
コード例 #14
0
 public CheckOutStatistic()
 {
     InitializeComponent();
     checkOutService = CheckOutServiceBean.getBean();
 }
コード例 #15
0
ファイル: Circular.cs プロジェクト: vkhorikov/UnitTestingPPP
 public void GenerateReport(
     int orderId,
     CheckOutService checkOutService)
 {
     /* calls checkOutService when generation is completed */
 }
コード例 #16
0
 public CheckOutController(LibraryContext _context, CheckOutService checkOutService, BranchesService branchesService)
 {
     this.checkOutService = checkOutService;
     this.branchesService = branchesService;
 }
コード例 #17
0
 public CheckOutForm()
 {
     InitializeComponent();
     checkOutService = CheckOutServiceBean.getBean();
 }
コード例 #18
0
ファイル: UnitTest1.cs プロジェクト: sabertooth13/ELMTest04
        public void TestCartCheckOut()
        {
            // we need to be able to apply offers to a specific group of products.[like all products in a
            // given category or something .
            // For the purpose of demonstration i am interchanginly using ProductName as ProductType because
            // it would be easy to add new products in future and apply same discount all the products of the same type if we wish so.

            /*
             * List<Product> products = new List<Product>()
             * {
             *  new Product{Id=1,Name=ProductType.A,Price=new Price(20)},
             *  new Product{Id=2,Name=ProductType.B,Price=new Price(4)},
             *  new Product{Id=3,Name=ProductType.c,Price=new Price(2)}
             * };
             *
             * this is the product store we are dealing with right now in these unit tests.
             *
             *
             */

            ProductService productService = new ProductService(new ProductRepository());

            productService.ApplyOfferToProducts(ProductType.A);
            productService.ApplyOfferToProducts(ProductType.B);
            productService.ApplyOfferToProducts(ProductType.c);
            Cart cart = new Cart(new ProductRepository());


            // to add a product to the cart , we give the productID and no of Products;


            int cartItmQty1 = 2;

            cart.AddItem(1, cartItmQty1);
            int cartItmQty2 = 3;

            cart.AddItem(2, cartItmQty2);
            int cartItmQty3 = 5;

            cart.AddItem(3, cartItmQty3);
            CheckOutService checkOut = new CheckOutService();

            checkOut.CalcualteTotal(cart.GetTotalItemsOrdered());
            Assert.AreEqual(40, checkOut.Total);



            // this portion of code is for displaying the results


            string opHead = string.Format("Item\tQuantity\tPricet\tTotal\tPromotion");
            string opl1   = string.Format("{0}\t{1}\t${2}\t${3}\t{4}", "A", cartItmQty1, "20", checkOut.Buy1Get1Total, "Buy 1 Get 1 Free");
            string opl2   = string.Format("{0}\t{1}\t${2}\t${3}\t{4}", "B", cartItmQty2, "4", checkOut.ThreeFor10Total, "3 for 10 Euro");
            string opl3   = string.Format("{0}\t{1}\t${2}\t${3}\t{4}", "C", cartItmQty3, "2", checkOut.NoOfferTotal, "");
            string tot    = string.Format("\tTotal \t \t${0}", checkOut.Total);

            Console.WriteLine(opHead);
            Console.WriteLine(opl1);
            Console.WriteLine(opl2);
            Console.WriteLine(opl3);
            Console.WriteLine(tot);
        }
コード例 #19
0
 public CheckOutInsertUpdateForm(CheckOutForm checkOutForm)
 {
     InitializeComponent();
     this.checkOutForm = checkOutForm;
     checkOutService   = CheckOutServiceBean.getBean();
 }