示例#1
0
        public void ShouldRequireMinimumFields()
        {
            var command = new ShippOrderCommand();

            FluentActions.Invoking(() =>
                                   SendAsync(command))
            .Should()
            .Throw <BaseValidationException>();
        }
示例#2
0
        public void ShouldThrowOrderNotFoundException()
        {
            // Cancel Order Command
            var shippOrderCommand = new ShippOrderCommand {
                OrderId = Guid.NewGuid().ToString()
            };

            FluentActions.Invoking(() => SendAsync(shippOrderCommand)).Should().Throw <OrderNotFoundException>();
        }
示例#3
0
        public async Task <IActionResult> ShippOrder([FromBody] ShippOrderCommand command)
        {
            var result = await Mediator.Send(command);

            return(Ok(result));
        }
示例#4
0
        public async Task ShouldShippOrder()
        {
            // Arrange
            var accountId = await RunAsDefaultUserAsync();

            var createCustomerCommand = new CreateCustomerCommand
            {
                AccountId     = accountId,
                ShopName      = "Test Shop Name",
                ShopAddress   = "Test Shop address",
                LocationOnMap = "Test LocationOnMap"
            };

            await SendAsync(createCustomerCommand);

            // Create product brand
            var brandCommand = new CreateBrandCommand {
                Name = "Test Brand"
            };
            var brandId = await SendAsync(brandCommand);

            // Create product category
            var productCategoryCommand = new CreateProductCategoryCommand {
                Name = "Test Product Category"
            };
            var productCategoryId = await SendAsync(productCategoryCommand);

            // Create product
            var createProductCommand = new CreateProductCommand
            {
                AvailableToSell = true,
                // created brand id
                BrandId = brandId,
                // created product category id
                ProductCategoryId = productCategoryId,
                Name     = "Test Product",
                PhotoUrl = "Test Product",
                Barcode  = "Test Product"
            };

            var productId = await SendAsync(createProductCommand);

            // Add unit to product
            var addUnitToCommand = new AddUnitCommand
            {
                ProductId    = productId,
                SellingPrice = 92,
                ContentCount = 2,
                Price        = 33,
                Count        = 6,
                IsAvailable  = true,
                Name         = "Test Unit",
                Weight       = 44
            };

            var unitId = await SendAsync(addUnitToCommand);

            // AddItem To Shopping Van
            var addItemToVanCommand = new AddItemToVanCommand
            {
                ProductId = productId,
                UnitId    = unitId
            };

            await SendAsync(addItemToVanCommand);
            await SendAsync(addItemToVanCommand);

            // Place Order Command
            var placeOrderCommand = new PlaceOrderCommand();
            var orderId           = await SendAsync(placeOrderCommand);

            // Confirm Order Command
            var confirmOrderCommand = new ConfirmOrderCommand {
                OrderId = orderId
            };

            await SendAsync(confirmOrderCommand);

            // Act

            // Shipp Order Command
            var shippOrderCommand = new ShippOrderCommand {
                OrderId = orderId
            };

            await SendAsync(shippOrderCommand);

            // Get Order By Id Query
            var orderByIdQuery = new OrderByIdQuery {
                OrderId = orderId
            };
            var order = await SendAsync(orderByIdQuery);

            // Assert
            order.Should().NotBeNull();
            order.OrderStatus.Should().Be(OrderStatus.Shipped);
        }
示例#5
0
        public async Task ShouldThrowOrderNotConfirmedException()
        {
            // Arrange
            var accountId = await RunAsDefaultUserAsync();

            var createCustomerCommand = new CreateCustomerCommand
            {
                AccountId     = accountId,
                ShopName      = "Test Shop Name",
                ShopAddress   = "Test Shop address",
                LocationOnMap = "Test LocationOnMap"
            };

            await SendAsync(createCustomerCommand);

            // Create product brand
            var brandCommand = new CreateBrandCommand {
                Name = "Test Brand"
            };
            var brandId = await SendAsync(brandCommand);

            // Create product category
            var productCategoryCommand = new CreateProductCategoryCommand {
                Name = "Test Product Category"
            };
            var productCategoryId = await SendAsync(productCategoryCommand);

            // Create product
            var createProductCommand = new CreateProductCommand
            {
                AvailableToSell = true,
                // created brand id
                BrandId = brandId,
                // created product category id
                ProductCategoryId = productCategoryId,
                Name     = "Test Product",
                PhotoUrl = "Test Product",
                Barcode  = "Test Product"
            };

            var productId = await SendAsync(createProductCommand);

            // Add unit to product
            var addUnitToCommand = new AddUnitCommand
            {
                ProductId    = productId,
                SellingPrice = 92,
                ContentCount = 2,
                Price        = 33,
                Count        = 6,
                IsAvailable  = true,
                Name         = "Test Unit",
                Weight       = 44
            };

            var unitId = await SendAsync(addUnitToCommand);

            // AddItem To Shopping Van
            var addItemToVanCommand = new AddItemToVanCommand
            {
                ProductId = productId,
                UnitId    = unitId
            };

            await SendAsync(addItemToVanCommand);
            await SendAsync(addItemToVanCommand);

            // Place Order Command
            var placeOrderCommand = new PlaceOrderCommand();
            var orderId           = await SendAsync(placeOrderCommand);

            // Act
            var cancelOrderCommand = new CancelOrderCommand {
                OrderId = orderId
            };

            await SendAsync(cancelOrderCommand);

            var shippOrderCommand = new ShippOrderCommand {
                OrderId = orderId
            };

            // Assert

            // Shipp Order Command
            FluentActions.Invoking(() => SendAsync(shippOrderCommand)).Should().Throw <OrderNotConfirmedException>();
        }