Exemplo n.º 1
0
        public async Task AcquireOrderShouldWorkProperly()
        {
            var orderRepository = new Mock <IRepository <Order> >();

            orderRepository.Setup(x => x.All()).Returns(this.DummyDataOrders().AsQueryable());

            var orderStatusRepository = new Mock <IRepository <OrderStatus> >();

            orderStatusRepository.Setup(x => x.All()).Returns(this.DummyDataOrderStatuses().AsQueryable());

            var orderService = new OrderService(orderRepository.Object, orderStatusRepository.Object, null, null);

            var actualResult = await orderService.AcquiredOrder("1");

            Assert.True(actualResult == true, "AcquiredOrder should return true upon successfully changing the status of the order.");
            orderRepository.Verify(x => x.All(), Times.Once, "All method of Order Repository should be called once.");
            orderStatusRepository.Verify(x => x.All(), Times.Once, "All method of Order Status Repository should be called once.");
            orderRepository.Verify(x => x.Update(It.IsAny <Order>()), Times.Once, "Update method of Order Repository should be called once.");
            orderRepository.Verify(x => x.SaveChangesAsync(), Times.Once, "SaveChangesAsync method of Order Repository should be called once.");
        }