Пример #1
0
        public void ProcessOrder_BookName_Empty_Test()
        {
            //arrange
            var video = GetProductInfo().Where(x => x.ProductType == Models.ProductTypes.VIDEO).FirstOrDefault();

            OrderProcess      = ProcessOrders.GetPaymentMethod(Models.PaymentType.VIDEO);
            video.Description = string.Empty;

            var ex = Assert.Throws <InvalidOperationException>(() => OrderProcess.ProcessPayment(video));

            Assert.That(ex.Message, Is.EqualTo("Video Descrption is missing"));
        }
        public void ProcessOrder_PhysicalProduct_Name_Empty_Test()
        {
            //arrange
            var product = GetProductInfo().Where(x => x.ProductType == Models.ProductTypes.PHYSICAL_PRODUCT).FirstOrDefault();

            product.Name = string.Empty;
            OrderProcess = ProcessOrders.GetPaymentMethod(Models.PaymentType.PHYSICAL_PRODUCT);

            //assert
            var ex = Assert.Throws <InvalidOperationException>(() => OrderProcess.ProcessPayment(product));

            Assert.That(ex.Message, Is.EqualTo("Physical Product Name is missing"));
        }
        public void Process_Empty_PhysicalProduct()
        {
            //Arrange
            var product = GetProductInfo().Where(x => x.ProductType == BL.Models.ProductFor.BOOKORPHYSICAL).FirstOrDefault();

            product.AgentName = string.Empty;
            OrderProcess      = ProcessOrders.GetPaymentMethod(BL.Models.PaymentFor.BOOKORPHYSICAL);

            //Act
            var ex = OrderProcess.ProcessPayment(product);

            //Assert
            Assert.AreEqual(ex.Message, "Agent Name is missing.");
        }
        public void ProcessOrder_BookName_Empty_Test()
        {
            //arrange
            var book = GetProductInfo().Where(x => x.ProductType == Models.ProductTypes.BOOK).FirstOrDefault();

            book.Name    = string.Empty;
            OrderProcess = ProcessOrders.GetPaymentMethod(Models.PaymentType.BOOK);
            double royaltyAmount = book.Price * book.Quantity * book.Commission;

            //assert
            var ex = Assert.Throws <InvalidOperationException>(() => OrderProcess.ProcessPayment(book));

            Assert.That(ex.Message, Is.EqualTo("Book Name is missing"));
        }
Пример #5
0
        public void Process_Empty_PhysicalProduct()
        {
            //arrange
            var video = GetProductInfo().Where(x => x.ProductType == BL.Models.ProductFor.VIDEO).FirstOrDefault();

            OrderProcess      = ProcessOrders.GetPaymentMethod(BL.Models.PaymentFor.VIDEO);
            video.Description = string.Empty;

            //Act
            var ex = OrderProcess.ProcessPayment(video);

            //Assert
            Assert.AreEqual(ex.Message, "Video Descrption is missing");
        }
        public void When_I_Pass_Valid_PhysicalProduct_Order_it_should_process()
        {
            //arrange
            var physcialProduct = GetProductInfo().Where(x => x.ProductType == Models.ProductTypes.PHYSICAL_PRODUCT).FirstOrDefault();

            OrderProcess = ProcessOrders.GetPaymentMethod(Models.PaymentType.PHYSICAL_PRODUCT);


            //act
            var result = OrderProcess.ProcessPayment(physcialProduct);

            //assert
            Assert.IsTrue(result.IsSuccess);
            Assert.AreEqual("Packing slip for shipping generated for physical product", result.Message);
        }
Пример #7
0
        public void Process_Empty_BookOrder()
        {
            //arrange
            var book = GetProductInfo().Where(x => x.ProductType == BL.Models.ProductFor.BOOK).FirstOrDefault();

            book.Name    = string.Empty;
            OrderProcess = ProcessOrders.GetPaymentMethod(BL.Models.PaymentFor.BOOK);
            double royaltyAmount = book.Price * book.Quantity * book.Commission;

            //Act
            var ex = OrderProcess.ProcessPayment(book);

            //assert

            Assert.AreEqual(ex.Message, "Book Name is missing");
        }
Пример #8
0
        public void Valid_BookOrder()
        {
            //Arrange
            var book = GetProductInfo().Where(x => x.ProductType == BL.Models.ProductFor.BOOK).FirstOrDefault();

            OrderProcess = ProcessOrders.GetPaymentMethod(BL.Models.PaymentFor.BOOK);
            double royaltyAmount = book.Price * book.Quantity * book.Commission;
            string message       = "Payment slip created with Amount -" + royaltyAmount;

            //Act
            var result = OrderProcess.ProcessPayment(book);

            //Assert
            Assert.IsTrue(result.IsSuccess);
            Assert.AreEqual(message, result.Message);
        }
        public void When_I_Pass_Valid_BookOrder_it_should_process()
        {
            //arrange
            var book = GetProductInfo().Where(x => x.ProductType == Models.ProductTypes.BOOK).FirstOrDefault();

            OrderProcess = ProcessOrders.GetPaymentMethod(Models.PaymentType.BOOK);
            double royaltyAmount = book.Price * book.Quantity * book.Commission;
            string message       = "Royalty payment slip created with Amount -" + royaltyAmount;

            //act
            var result = OrderProcess.ProcessPayment(book);

            //assert
            Assert.IsTrue(result.IsSuccess);
            Assert.AreEqual(message, result.Message);
        }
Пример #10
0
        public void When_I_Pass_Valid_VideoOrder_it_should_process()
        {
            //arrange
            var video = GetProductInfo().Where(x => x.ProductType == Models.ProductTypes.VIDEO).FirstOrDefault();

            OrderProcess        = ProcessOrders.GetPaymentMethod(Models.PaymentType.VIDEO);
            video.Description   = "TestVideos";
            video.PackagingDate = DateTime.Today;

            //act
            var result = OrderProcess.ProcessPayment(video);

            //assert
            Assert.IsTrue(result.IsSuccess);
            Assert.AreEqual("Generated Packing slip", result.Message);
        }
Пример #11
0
        public void Valid_VideoOrder()
        {
            //arrange
            var video = GetProductInfo().Where(x => x.ProductType == BL.Models.ProductFor.VIDEO).FirstOrDefault();

            OrderProcess        = ProcessOrders.GetPaymentMethod(BL.Models.PaymentFor.VIDEO);
            video.Description   = "learning to msi";
            video.PackagingDate = DateTime.Today;

            //act
            var result = OrderProcess.ProcessPayment(video);

            //assert
            Assert.IsTrue(result.IsSuccess);
            Assert.AreEqual("Added First Aid video to the packing slip.", result.Message);
        }
        public void Valid_PhysicalProduct_Order()
        {
            //arrange
            var physcialProduct = GetProductInfo().Where(x => x.ProductType == BL.Models.ProductFor.BOOKORPHYSICAL).FirstOrDefault();

            double Commission = (physcialProduct.Quantity * physcialProduct.Price) / 0.20;

            OrderProcess = ProcessOrders.GetPaymentMethod(BL.Models.PaymentFor.BOOKORPHYSICAL);
            string message = "Commision paid to agent -" + Commission;

            //act
            var result = OrderProcess.ProcessPayment(physcialProduct);

            //assert
            Assert.IsTrue(result.IsSuccess);
            Assert.AreEqual(message, result.Message);
        }
Пример #13
0
        private static void ProcessPayment(int options)
        {
            int memberShipType = 0;
            var paymentType    = (PaymentType)Enum.Parse(typeof(PaymentType), options.ToString());

            if (options == 3 || options == 6)
            {
                paymentType    = (PaymentType)Enum.Parse(typeof(PaymentType), "3".ToString());
                memberShipType = options == 3 ? 1 : 2;
                var result      = ProcessOrders.GetPaymentMethod(paymentType);
                var sampleInput = SampleInput.GetSampleDataMember(memberShipType);

                if (result != null)
                {
                    var data = result.ProcessPayment(sampleInput);

                    Console.WriteLine($"Order of {paymentType.ToString()} and  {data.Message}\n");
                }
                else
                {
                    Console.WriteLine("Invalid operation");
                }
            }
            else
            {
                IProcessOrder processor = ProcessOrders.GetPaymentMethod(paymentType);
                var           data      = SampleInput.GetSampleDataForOrder(paymentType);
                if (processor != null)
                {
                    var result = processor.ProcessPayment(data);

                    Console.WriteLine($"Order of {paymentType.ToString()} and  {result.Message}\n");
                }
                else
                {
                    Console.WriteLine("Invalid operation");
                }
            }
        }