public void ShouldRequireMinimumFields() { var command = new ShippOrderCommand(); FluentActions.Invoking(() => SendAsync(command)) .Should() .Throw <BaseValidationException>(); }
public void ShouldThrowOrderNotFoundException() { // Cancel Order Command var shippOrderCommand = new ShippOrderCommand { OrderId = Guid.NewGuid().ToString() }; FluentActions.Invoking(() => SendAsync(shippOrderCommand)).Should().Throw <OrderNotFoundException>(); }
public async Task <IActionResult> ShippOrder([FromBody] ShippOrderCommand command) { var result = await Mediator.Send(command); return(Ok(result)); }
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); }
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>(); }