public async Task ShouldBumpCustomer()
        {
            var sut = new SetCustomerStatusStep(new CustomerStatusLevelRepository(), new TestCustomerStatusSettings());

            var customer = CustomerStatusHelperTest.GetCustomer("Silver",
                                                                1,
                                                                new List <Order>()
            {
                CustomerStatusHelperTest.GetOrder(DateTime.UtcNow, 700),
            });

            var order   = CustomerStatusHelperTest.GetOrder(DateTime.UtcNow, 700);
            var context = new OrderContext(order)
            {
                Customer = customer,
            };


            var result = await sut.Run(
                context

                );

            Assert.IsTrue(result.IsSuccess);
            Assert.AreEqual(2, context.Customer.Status.Level);
        }
Пример #2
0
        public async Task WhenNotAllItemsAreInStockThenReturnFail()
        {
            var stockItemCheckStep = new CheckItemStockStep(new ProductRepository());
            var customer           = CustomerStatusHelperTest.GetCustomer("Silver",
                                                                          1,
                                                                          new List <Order>()
            {
                CustomerStatusHelperTest.GetOrder(DateTime.UtcNow, 700),
            });

            var order   = GetOrder(DateTime.UtcNow, 700, 3);
            var context = new OrderContext(order)
            {
                Customer = customer,
            };

            var result = await stockItemCheckStep.Run(context);

            Assert.IsTrue(result.IsFailure);
        }
Пример #3
0
        public async Task WhenAllItemsAreInStockThenReturnOK()
        {
            var stockItemCheckStep = new CheckItemStockStep(new ProductRepository());
            var customer           = CustomerStatusHelperTest.GetCustomer("Silver",
                                                                          1,
                                                                          new List <Order>()
            {
                CustomerStatusHelperTest.GetOrder(DateTime.UtcNow, 700),
            });

            var order   = GetOrder(DateTime.UtcNow, 700, 1);
            var context = new OrderContext(order)
            {
                Customer = customer,
            };

            var result = await stockItemCheckStep.Run(context);

            Assert.IsTrue(result.IsSuccess);
            Assert.AreEqual("All items are in stock", result.Value);
        }