Ejemplo n.º 1
0
        public async Task GetAllProcessed_ReturnsCorectly()
        {
            MapperInitializer.InitializeMapper();
            var context         = ApplicationDbContextInMemoryFactory.InitializeContext();
            var orderRepository = new EfDeletableEntityRepository <Order>(context);
            var orderService    = this.GetOrderService(orderRepository, context);
            var orderTestSeeder = new OrderTestSeeder();

            await orderTestSeeder.SeedOneProcessedOrder(context);

            var result = orderService.GetAllProcessed <OrderProcessedViewModel>();

            Assert.Single(result);
        }
Ejemplo n.º 2
0
        public async Task Process_WorksCorectly()
        {
            var context         = ApplicationDbContextInMemoryFactory.InitializeContext();
            var orderRepository = new EfDeletableEntityRepository <Order>(context);
            var orderService    = this.GetOrderService(orderRepository, context);
            var orderTestSeeder = new OrderTestSeeder();

            await orderTestSeeder.SeedOneProcessedOrder(context);

            var order = context.Orders.FirstOrDefault();

            await orderService.Process(order.Id);

            Assert.Equal(OrderStatus.Proccessed, order.OrderStatus);

            await Assert.ThrowsAsync <ArgumentNullException>(async() =>
            {
                await orderService.Finish("invalid");
            });
        }
Ejemplo n.º 3
0
        public async Task Delete_WorksCorectly()
        {
            var context         = ApplicationDbContextInMemoryFactory.InitializeContext();
            var orderRepository = new EfDeletableEntityRepository <Order>(context);
            var orderService    = this.GetOrderService(orderRepository, context);
            var orderTestSeeder = new OrderTestSeeder();

            await orderTestSeeder.SeedOneUnprocessedOrder(context);

            var unProcessed = context.Orders.First(x => x.Recipient == "UnProcessed");

            await orderTestSeeder.SeedOneProcessedOrder(context);

            var processed = context.Orders.First(x => x.Recipient == "Processed");

            await orderTestSeeder.SeedOneDeliveredOrder(context);

            var delivered = context.Orders.First(x => x.Recipient == "Delivered");


            await orderService.Delete(unProcessed.Id);

            await orderService.Delete(processed.Id);

            await orderService.Delete(delivered.Id);

            var orders = context.Orders.Count();

            Assert.True(delivered.IsDeleted);

            Assert.Equal(0, orders);

            await Assert.ThrowsAsync <ArgumentNullException>(async() =>
            {
                await orderService.Delete("invalid");
            });
        }