public async Task Review_WithCorrectOrderId_ShouldReturnValidViewModel()
        {
            //Arrange
            Mock <IOrderService> orderService = new Mock <IOrderService>();

            orderService
            .Setup(o => o.IsOrderExistingById(orderId))
            .ReturnsAsync(true);
            orderService
            .Setup(o => o.GetDetailsByIdAsync(orderId))
            .ReturnsAsync(new OrderDetailsServiceModel()
            {
                Supplements = new List <SupplementInOrderServiceModel>()
            });

            OrdersController ordersController = new OrdersController(null, orderService.Object, null);

            //Act
            var result = await ordersController.Review(orderId);

            //Assert
            result.Should().BeOfType <ViewResult>();

            result.As <ViewResult>().Model.Should().BeOfType <OrderDetailsServiceModel>();

            OrderDetailsServiceModel model = result.As <ViewResult>().Model.As <OrderDetailsServiceModel>();

            model.Supplements.Should().HaveCount(0);
        }
Example #2
0
        public async Task <IActionResult> Review(int id)
        {
            bool isOrderExistingById = await this.orderService.IsOrderExistingById(id);

            if (!isOrderExistingById)
            {
                return(this.RedirectToHomeIndex());
            }

            OrderDetailsServiceModel model = await this.orderService.GetDetailsByIdAsync(id);

            return(View(model));
        }
        public async Task <IActionResult> Review(int id)
        {
            bool isOrderExistingById = await this.orderService.IsOrderExistingById(id);

            if (!isOrderExistingById)
            {
                return(RedirectToAction(nameof(Index)));
            }

            OrderDetailsServiceModel model = await this.orderService.GetDetailsByIdAsync(id);

            string username = await this.adminUserService.GetUsernameByOrderIdAsync(id);

            ViewData["Username"] = username;

            return(View(model));
        }
Example #4
0
        public async Task GetDetailsByIdAsync_WithOrderId_ShouldReturnValidServiceModel()
        {
            // Arrange
            FitStoreDbContext database = this.Database;

            DatabaseHelper.SeedData(database);

            IOrderService orderService = new OrderService(database);

            // Act
            OrderDetailsServiceModel result = await orderService.GetDetailsByIdAsync(orderId);

            // Assert
            result.Id.Should().Be(1);
            result.TotalPrice.Should().Be(1);
            result.Supplements.Count().Should().Be(1);
        }