Exemplo n.º 1
0
        public async Task WhenInventoryInsufficient_ShouldReturnOrderStatusFailed()
        {
            _mockInventory.Setup(x => x.CheckInventory(It.IsAny <string>(), It.IsAny <int>())).Returns(false);

            var orderDetails = new OrderDetails()
            {
                Products = new List <OrderedProduct>()
                {
                    new OrderedProduct()
                    {
                        Product = new Product {
                            ProductId = "1", Name = "Prod1", UnitPrice = 11
                        }, Quantity = 5, TotalPrice = 55
                    }
                },
                OrderNumber    = 1234,
                OrderTotal     = 55,
                PaymentDetails = new Payment {
                    CreditCardNumber = "4111111111111"
                },
                BillingAddress = new Address {
                    ContactDetails = new Contact {
                        FirstName = "FN", LastName = "LN", Email = "*****@*****.**"
                    }, Address1 = "add1", State = "AZ", Country = "US", Zip = "54634"
                },
                ShippingAddress = new Address {
                    ContactDetails = new Contact {
                        FirstName = "FN", LastName = "LN", Email = "*****@*****.**"
                    }, Address1 = "add1", State = "AZ", Country = "US", Zip = "54634"
                }
            };
            var result = await _sut.Process(orderDetails);

            Assert.False(result.IsSuccess);
            Assert.Equal($"Insufficient inventory for Product:{orderDetails.Products[0].Product.Name} ", result.ProcessingStatusMessage);
        }
Exemplo n.º 2
0
        static async Task Main(string[] args)
        {
            Console.Clear();
            Console.WriteLine("Hi! This is a very awesome tic tac toe game status analyzer");
            var url         = GetUrlFromUserInput();
            var importLines = await DownloadStatusFileAsync(url);

            var service       = new OrderProcessingService();
            var shipmentLines = service.Process(importLines);

            Console.WriteLine("CustomerId,Name,Shipper,Duration,ShippingCost");
            foreach (var shipmentLine in shipmentLines)
            {
                Console.WriteLine($"{shipmentLine.CustomerId},{shipmentLine.Name},{shipmentLine.Shipper},{shipmentLine.Duration},{shipmentLine.ShippingCost}");
            }

            Console.WriteLine();

            Console.ReadKey();
        }
Exemplo n.º 3
0
        public void WhenOrderIsProcessed_IsReturnsShipmentInformation()
        {
            var order = new OrderBuilder()
                        .WithCountry("Netherlands")
                        .WithWeight(6)
                        .Build();

            var orderProcessor = new OrderProcessingService();
            var shipmentInfo   = orderProcessor.Process(new List <string>
            {
                order.ToString()
            });

            Assert.AreEqual(1, shipmentInfo.Count());

            var shipment = shipmentInfo.FirstOrDefault();

            Assert.AreEqual(order.CustomerId, shipment.CustomerId);
            Assert.AreEqual(order.Name, shipment.Name);
            Assert.AreEqual("PostNL", shipment.Shipper);
            Assert.AreEqual(1, shipment.Duration);
            Assert.AreEqual(6.95M, shipment.ShippingCost);
        }