Пример #1
0
        public async Task GetOrderByIdWihtNonExistantIdShouldReturnNull()
        {
            var context = InMemoryDatabase.GetDbContext();

            await SeedData(context);

            var orderService = new Mock <IOrderService>();

            var fakeId            = "nonexistent";
            var methodReturnValue = new OrderByStatusViewModel();

            orderService.Setup(g => g.GetOrderById <OrderByStatusViewModel>("Id")).Returns(methodReturnValue);

            var service      = orderService.Object;
            var actualResult = service.GetOrderById <OrderByStatusViewModel>(fakeId);

            Assert.Null(actualResult);
        }
Пример #2
0
        public async Task GetOrderByIdShouldReturnTheCorrectOrder()
        {
            var context = InMemoryDatabase.GetDbContext();

            await SeedData(context);

            var mockOrderService = new Mock <IOrderService>();

            var methodReturnValue = new OrderByStatusViewModel();
            var expectedResult    = GetTestData().First();

            mockOrderService.Setup(g => g.GetOrderById <OrderByStatusViewModel>(expectedResult.Id)).Returns(methodReturnValue);

            var service       = mockOrderService.Object;
            var returnedOrder = service.GetOrderById <OrderByStatusViewModel>(expectedResult.Id);

            Assert.Same(expectedResult.Clothing.Name, returnedOrder.ClothingName);
        }