Пример #1
0
        public async Task DeletePaymentShouldAddPaymentAndUpdateStatus()
        {
            var options = new DbContextOptionsBuilder <WHMSDbContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;

            using var context = new WHMSDbContext(options);
            var warehouse = new Warehouse
            {
                Address = new Address {
                },
                Name    = "Test",
            };
            var product = new Product
            {
                ProductName = "Test Product",
            };
            var productWarehouse = new ProductWarehouse
            {
                Product               = product,
                Warehouse             = warehouse,
                AggregateQuantity     = 0,
                TotalPhysicalQuanitiy = 10,
                ReservedQuantity      = 5,
            };

            context.Warehouses.Add(warehouse);
            context.Products.Add(product);
            context.ProductWarehouses.Add(productWarehouse);
            var order = new Order {
                WarehouseId = warehouse.Id, GrandTotal = 100
            };

            context.Orders.Add(order);
            var orderItem = new OrderItem {
                OrderId = order.Id, ProductId = product.Id, Qty = 3
            };

            context.Orders.Add(order);
            context.OrderItems.Add(orderItem);
            var payment = new Payment {
                Amount = 100, OrderId = order.Id,
            };

            context.Payments.Add(payment);
            await context.SaveChangesAsync();

            var mockInventoryService = new Mock <IInventoryService>();
            var mockCustomersService = new Mock <ICustomersService>();

            var service = new OrdersService(context, mockInventoryService.Object, mockCustomersService.Object);
            await service.DeletePaymentAsync(payment.Id);

            var paymentDb = context.Payments.FirstOrDefault();

            Assert.Null(paymentDb);
            Assert.True(order.PaymentStatus == PaymentStatus.NoPayment);
        }
Пример #2
0
        public async Task AddOrderItemsShouldAddNewItemsToOrder()
        {
            var options = new DbContextOptionsBuilder <WHMSDbContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;

            using var context = new WHMSDbContext(options);
            var warehouse = new Warehouse
            {
                Address = new Address {
                },
                Name    = "Test",
            };
            var product = new Product
            {
                ProductName = "Test Product",
            };
            var productWarehouse = new ProductWarehouse
            {
                Product               = product,
                Warehouse             = warehouse,
                AggregateQuantity     = 0,
                TotalPhysicalQuanitiy = 10,
                ReservedQuantity      = 5,
            };

            context.Warehouses.Add(warehouse);
            context.Products.Add(product);
            context.ProductWarehouses.Add(productWarehouse);
            var order = new Order {
                WarehouseId = warehouse.Id
            };

            context.Orders.Add(order);
            await context.SaveChangesAsync();

            var mockInventoryService = new Mock <IInventoryService>();
            var mockOrdersService    = new Mock <IOrdersService>();
            var service = new OrderItemsService(context, mockInventoryService.Object, mockOrdersService.Object);
            var model   = new AddOrderItemsInputModel {
                OrderId = order.Id, OrderItems = new List <AddOrderItemViewModel> {
                    new AddOrderItemViewModel {
                        ProductId = product.Id, Price = 100, Qty = 10
                    }
                }
            };

            var id = await service.AddOrderItemAsync(model);

            var orderItemDB = context.OrderItems.FirstOrDefault();

            Assert.NotNull(orderItemDB);
            Assert.Equal(order.Id, id);
            Assert.True(orderItemDB.OrderId == order.Id);
            Assert.True(orderItemDB.ProductId == product.Id);
        }
Пример #3
0
        public async Task AddOrderItemsShouldUpdateQtyIfItemsIsAlreadyAddedWhenAddingItemsFromProduct()
        {
            var options = new DbContextOptionsBuilder <WHMSDbContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;

            using var context = new WHMSDbContext(options);
            var warehouse = new Warehouse
            {
                Address = new Address {
                },
                Name    = "Test",
            };
            var product = new Product
            {
                ProductName = "Test Product",
            };
            var productWarehouse = new ProductWarehouse
            {
                Product               = product,
                Warehouse             = warehouse,
                AggregateQuantity     = 0,
                TotalPhysicalQuanitiy = 10,
                ReservedQuantity      = 5,
            };

            context.Warehouses.Add(warehouse);
            context.Products.Add(product);
            context.ProductWarehouses.Add(productWarehouse);
            var order = new Order {
                WarehouseId = warehouse.Id
            };

            context.Orders.Add(order);
            var orderItem = new OrderItem {
                OrderId = order.Id, ProductId = product.Id, Qty = 3
            };

            context.OrderItems.Add(orderItem);
            await context.SaveChangesAsync();

            var mockInventoryService = new Mock <IInventoryService>();
            var mockOrdersService    = new Mock <IOrdersService>();
            var service = new OrderItemsService(context, mockInventoryService.Object, mockOrdersService.Object);
            var model   = new AddProductToOrderInputModel {
                OrderId = order.Id, ProductId = product.Id, Qty = -3
            };

            var id = await service.AddOrderItemAsync(model);

            var orderItemDB = context.OrderItems.FirstOrDefault();

            Assert.Null(orderItemDB);
        }
Пример #4
0
        public async Task GetPhysicalInventoryShouldReturnPositiveWithPositiveAggregateInventoryInMultipleWarehouses()
        {
            var options = new DbContextOptionsBuilder <WHMSDbContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;

            using var context = new WHMSDbContext(options);
            var warehouse = new Warehouse
            {
                Address = new Address {
                },
                Name    = "Test",
            };
            var warehouse2 = new Warehouse
            {
                Address = new Address {
                },
                Name    = "Test",
            };
            var product = new Product
            {
                ProductName = "Test Product",
            };
            var productWarehouse = new ProductWarehouse
            {
                Product               = product,
                Warehouse             = warehouse,
                AggregateQuantity     = 5,
                TotalPhysicalQuanitiy = 5,
                ReservedQuantity      = 0,
            };
            var productWarehouse2 = new ProductWarehouse
            {
                Product               = product,
                Warehouse             = warehouse2,
                AggregateQuantity     = 12,
                TotalPhysicalQuanitiy = 12,
                ReservedQuantity      = 0,
            };

            context.Warehouses.Add(warehouse);
            context.Warehouses.Add(warehouse2);
            context.Products.Add(product);
            context.ProductWarehouses.Add(productWarehouse);
            context.ProductWarehouses.Add(productWarehouse2);
            await context.SaveChangesAsync();

            var service           = new InventoryService(context);
            var physicalInventory = service.GetProductPhysicalInventory(product.Id);
            var expected          = 17;

            Assert.Equal(expected, physicalInventory);
        }
Пример #5
0
        public async Task CancelOrderShouldSetOrderStatusToCancelled()
        {
            var options = new DbContextOptionsBuilder <WHMSDbContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;

            using var context = new WHMSDbContext(options);
            var warehouse = new Warehouse
            {
                Address = new Address {
                },
                Name    = "Test",
            };
            var product = new Product
            {
                ProductName = "Test Product",
            };
            var productWarehouse = new ProductWarehouse
            {
                Product               = product,
                Warehouse             = warehouse,
                AggregateQuantity     = 0,
                TotalPhysicalQuanitiy = 10,
                ReservedQuantity      = 5,
            };

            context.Warehouses.Add(warehouse);
            context.Products.Add(product);
            context.ProductWarehouses.Add(productWarehouse);
            var order = new Order {
                WarehouseId = warehouse.Id
            };

            context.Orders.Add(order);
            var orderItem = new OrderItem {
                OrderId = order.Id, ProductId = product.Id, Qty = 3
            };

            context.Orders.Add(order);
            context.OrderItems.Add(orderItem);
            await context.SaveChangesAsync();

            var mockInventoryService = new Mock <IInventoryService>();
            var mockCustomersService = new Mock <ICustomersService>();

            var service = new OrdersService(context, mockInventoryService.Object, mockCustomersService.Object);

            await service.CancelOrderAsync(order.Id);

            Assert.True(order.OrderStatus == OrderStatus.Cancelled);
            mockInventoryService.Verify(x => x.RecalculateAvailableInventoryAsync(It.IsAny <int>()), Times.AtLeastOnce);
        }
Пример #6
0
        public async Task DeleteBrandShouldReturnFalseBrandDoesNotExist()
        {
            var options = new DbContextOptionsBuilder <WHMSDbContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;

            using var context = new WHMSDbContext(options);
            await context.Brands.AddAsync(new Brand { Name = "Test" });

            await context.SaveChangesAsync();

            var service = new BrandsService(context);

            var success = await service.DeleteBrandAsync(20);

            Assert.False(success);
        }
Пример #7
0
        public async Task GetCustomersCountShouldBeCorrect()
        {
            var options = new DbContextOptionsBuilder <WHMSDbContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;

            using var context = new WHMSDbContext(options);
            context.Customers.Add(new Customer {
                Email = "*****@*****.**", FirstName = "Pesho", LastName = "Peshov", PhoneNumber = "000000", Address = new Address {
                }
            });
            await context.SaveChangesAsync();

            var service = new CustomersService(context);

            var count = service.CustomersCount();

            Assert.Equal(1, count);
        }
Пример #8
0
        public async Task GetProductWarehousesShouldReturnCorrectInfoWhenProductWarehouseExists()
        {
            var options = new DbContextOptionsBuilder <WHMSDbContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;

            using var context = new WHMSDbContext(options);
            var warehouse = new Warehouse
            {
                Address = new Address
                {
                    City          = "Test",
                    StreetAddress = "Test",
                    ZIP           = "test",
                    Country       = "Test",
                },
                Name = "Test",
            };
            var product = new Product
            {
                ProductName = "Test Product",
            };
            var productWarehouse = new ProductWarehouse
            {
                Product               = product,
                Warehouse             = warehouse,
                AggregateQuantity     = 0,
                TotalPhysicalQuanitiy = 0,
                ReservedQuantity      = 0,
            };

            context.Warehouses.Add(warehouse);
            context.Products.Add(product);
            context.ProductWarehouses.Add(productWarehouse);
            await context.SaveChangesAsync();

            var service = new WarehouseService(context);
            var serviceProductWarehouse = service.GetProductWarehouseInfo(product.Id).FirstOrDefault();

            Assert.Equal(productWarehouse.ProductId, serviceProductWarehouse.ProductId);
            Assert.Equal(productWarehouse.Warehouse.Name, serviceProductWarehouse.WarehouseName);
            Assert.Equal(productWarehouse.TotalPhysicalQuanitiy, serviceProductWarehouse.TotalPhysicalQuanitity);
            Assert.Equal(productWarehouse.TotalPhysicalQuanitiy, serviceProductWarehouse.AggregateQuantity);
            Assert.Equal(productWarehouse.TotalPhysicalQuanitiy, serviceProductWarehouse.ReservedQuantity);
        }
Пример #9
0
        public async Task GetAllBrandsShouldReturnMaxPageSize()
        {
            var options = new DbContextOptionsBuilder <WHMSDbContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;

            using var context = new WHMSDbContext(options);
            for (int i = 0; i < 100; i++)
            {
                await context.Brands.AddAsync(new Brand { Name = i.ToString() });
            }

            await context.SaveChangesAsync();

            var service = new BrandsService(context);

            var brands         = service.GetAllBrands <BrandViewModel>(1);
            var brandsCount    = brands.ToList().Count();
            var exepcetedCount = GlobalConstants.PageSize;

            Assert.Equal(exepcetedCount, brandsCount);
        }
Пример #10
0
        public async Task GetAllConditionsShouldReturnAllConditions()
        {
            var options = new DbContextOptionsBuilder <WHMSDbContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;

            using var context = new WHMSDbContext(options);
            for (int i = 0; i < 100; i++)
            {
                await context.ProductConditions.AddAsync(new ProductCondition { Name = i.ToString() });
            }

            await context.SaveChangesAsync();

            var service = new ConditionsService(context);

            var conditions      = service.GetAllConditions <ConditionViewModel>();
            var conditionsCount = conditions.ToList().Count();
            var exepcetedCount  = context.ProductConditions.Count();

            Assert.Equal(exepcetedCount, conditionsCount);
        }
Пример #11
0
        public async Task IsValidProduShouldReturnCorrectAnswer(int id, bool expected)
        {
            var options = new DbContextOptionsBuilder <WHMSDbContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;

            using var context = new WHMSDbContext(options);
            var product = new Product
            {
                Id = 123,
            };

            context.Products.Add(product);
            await context.SaveChangesAsync();

            var mockInventoryService = new Mock <IInventoryService>();
            var service = new ProductsService(context, mockInventoryService.Object);

            var result = service.IsValidProductId(id);

            Assert.Equal(expected, result);
        }
Пример #12
0
        public async Task AdjustInventoryShouldAdjustInventoryCorrectlyWithNegativeAdjustment()
        {
            var options = new DbContextOptionsBuilder <WHMSDbContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;

            using var context = new WHMSDbContext(options);
            var warehouse = new Warehouse
            {
                Address = new Address {
                },
                Name    = "Test",
            };
            var product = new Product
            {
                ProductName = "Test Product",
            };
            var productWarehouse = new ProductWarehouse
            {
                Product               = product,
                Warehouse             = warehouse,
                AggregateQuantity     = 0,
                TotalPhysicalQuanitiy = 10,
                ReservedQuantity      = 0,
            };

            context.Warehouses.Add(warehouse);
            context.Products.Add(product);
            context.ProductWarehouses.Add(productWarehouse);
            await context.SaveChangesAsync();

            var service    = new InventoryService(context);
            var adjustment = new ProductAdjustmentInputModel {
                ProductId = product.Id, Qty = -10, WarehouseId = warehouse.Id
            };
            await service.AdjustInventoryAsync(adjustment);

            productWarehouse = context.ProductWarehouses.FirstOrDefault();
            var expected = 0;

            Assert.Equal(expected, productWarehouse.TotalPhysicalQuanitiy);
            Assert.Equal(expected, productWarehouse.AggregateQuantity);
        }
Пример #13
0
        public async Task AddShippingMethodShouldCreateNewMethodIfItDoesntExist()
        {
            var options = new DbContextOptionsBuilder <WHMSDbContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;

            using var context = new WHMSDbContext(options);
            var mockInventoryService = new Mock <IInventoryService>();
            var service         = new ShippingService(context, mockInventoryService.Object);
            var shippingService = "FedEx";
            var carrier         = new Carrier {
                Name = shippingService
            };

            context.Carriers.Add(carrier);
            await context.SaveChangesAsync();

            await service.AddShippingMethodAsync(carrier.Id, shippingService);

            var shippingMethod = context.ShippingMethods.FirstOrDefault();

            Assert.NotNull(shippingMethod);
            Assert.Equal(shippingService, shippingMethod.Name);
        }
Пример #14
0
        public async Task IsSkuAvailableShouldReturnCorrectAnswer(string sku, bool expected)
        {
            var options = new DbContextOptionsBuilder <WHMSDbContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;

            using var context = new WHMSDbContext(options);
            var product = new Product
            {
                SKU              = "Test",
                ProductName      = "Test Product",
                ShortDescription = "Test Product",
            };

            context.Products.Add(product);
            await context.SaveChangesAsync();

            var mockInventoryService = new Mock <IInventoryService>();
            var service = new ProductsService(context, mockInventoryService.Object);

            var result = service.IsSkuAvailable(sku);

            Assert.Equal(expected, result);
        }
Пример #15
0
        public async Task AddCarrierShouldNotCreateNewCarrierIfExist()
        {
            var options = new DbContextOptionsBuilder <WHMSDbContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;

            using var context = new WHMSDbContext(options);
            var mockInventoryService = new Mock <IInventoryService>();
            var service     = new ShippingService(context, mockInventoryService.Object);
            var carrierName = "FedEx";
            var carrier     = new Carrier {
                Name = carrierName
            };

            context.Carriers.Add(carrier);
            await context.SaveChangesAsync();

            await service.AddCarrierAsync(carrierName);

            var carrierDb = context.Carriers.FirstOrDefault();

            Assert.Equal(carrierName, carrierDb.Name);
            Assert.Equal(carrier.Id, carrierDb.Id);
        }
Пример #16
0
        public async Task CreateProductShouldCreateNewProduct()
        {
            var options = new DbContextOptionsBuilder <WHMSDbContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;

            using var context = new WHMSDbContext(options);
            var product = new AddProductInputModel
            {
                ProductName      = "Test Product",
                ShortDescription = "Test Product",
            };

            await context.SaveChangesAsync();

            var mockInventoryService = new Mock <IInventoryService>();
            var service = new ProductsService(context, mockInventoryService.Object);

            var productId = await service.CreateProductAsync(product);

            var dbProduct = context.Products.FirstOrDefault();

            Assert.Equal(dbProduct.Id, productId);
            Assert.True(context.Products.Count() == 1);
        }
Пример #17
0
        public async Task GetCustomerShouldReturnCustomerIfExists()
        {
            var options = new DbContextOptionsBuilder <WHMSDbContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;

            using var context = new WHMSDbContext(options);
            context.Customers.Add(new Customer {
                Email = "*****@*****.**", FirstName = "Pesho", LastName = "Peshov", PhoneNumber = "000000", Address = new Address {
                }
            });
            await context.SaveChangesAsync();

            var service = new CustomersService(context);

            var customerFromService = service.GetCustomer <CustomerViewModel>("*****@*****.**");

            var dbCustomer = context.Customers.FirstOrDefault();

            Assert.NotNull(dbCustomer);
            Assert.Equal(customerFromService.Email, dbCustomer.Email);
            Assert.Equal(customerFromService.FirstName, dbCustomer.FirstName);
            Assert.Equal(customerFromService.LastName, dbCustomer.LastName);
            Assert.Equal(customerFromService.PhoneNumber, dbCustomer.PhoneNumber);
        }
Пример #18
0
        public async Task GetAllCustomersWithPagingShouldReturnOnly1Page()
        {
            var options = new DbContextOptionsBuilder <WHMSDbContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;

            using var context = new WHMSDbContext(options);
            for (int i = 0; i < 100; i++)
            {
                context.Customers.Add(new Customer {
                    Email = i + "@gmail.com", FirstName = "Pesho", LastName = "Peshov", PhoneNumber = "000000", Address = new Address {
                    }
                });
            }
            await context.SaveChangesAsync();

            var service = new CustomersService(context);

            var filters = new CustomersFilterInputModel {
                Page = 1
            };
            var customers = service.GetAllCustomers <CustomerViewModel>(filters);

            Assert.Equal(GlobalConstants.PageSize, customers.Count());
        }
Пример #19
0
        public async Task UpdateDefaultImage()
        {
            var options = new DbContextOptionsBuilder <WHMSDbContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;

            using var context = new WHMSDbContext(options);
            var product = new Product
            {
                ProductName      = "Test Product",
                ShortDescription = "Test Product",
            };

            context.Products.Add(product);
            await context.SaveChangesAsync();

            var image = new Image {
                ProductId = product.Id, Url = "https://c8.alamy.com/comp/D8RWP0/url-of-web-browser-D8RWP0.jpg", IsPrimary = false
            };
            var image2 = new Image {
                ProductId = product.Id, Url = "https://c8.alamy.com/comp/D8RWP0/url-of-web-browser-D8RWP0.jpg", IsPrimary = true
            };
            var image3 = new Image {
                ProductId = product.Id, Url = "https://c8.alamy.com/comp/D8RWP0/url-of-web-browser-D8RWP0.jpg", IsPrimary = true
            };

            context.Images.Add(image);
            context.Images.Add(image2);
            context.Images.Add(image3);
            context.SaveChanges();
            var mockInventoryService = new Mock <IInventoryService>();
            var service = new ProductsService(context, mockInventoryService.Object);

            await service.UpdateDefaultImageAsync(image.Id);

            Assert.True(image.IsPrimary);
            Assert.False(image2.IsPrimary);
            Assert.False(image3.IsPrimary);
        }
Пример #20
0
        public async Task RecalcualteAvaialbleInventoryShouldRecalculateReservedInventory()
        {
            var options = new DbContextOptionsBuilder <WHMSDbContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;

            using var context = new WHMSDbContext(options);
            var warehouse = new Warehouse
            {
                Address = new Address {
                },
                Name    = "Test",
            };
            var product = new Product
            {
                ProductName = "Test Product",
            };
            var productWarehouse = new ProductWarehouse
            {
                Product               = product,
                Warehouse             = warehouse,
                AggregateQuantity     = 0,
                TotalPhysicalQuanitiy = 10,
                ReservedQuantity      = 5,
            };

            context.Warehouses.Add(warehouse);
            context.Products.Add(product);
            context.ProductWarehouses.Add(productWarehouse);
            await context.SaveChangesAsync();

            var service = new InventoryService(context);
            await service.RecalculateAvailableInventoryAsync(product.Id);

            productWarehouse = context.ProductWarehouses.FirstOrDefault();
            var expected = 0;

            Assert.Equal(expected, productWarehouse.ReservedQuantity);
        }
Пример #21
0
        public async Task AddProductImageShouldAddNewImage()
        {
            var options = new DbContextOptionsBuilder <WHMSDbContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;

            using var context = new WHMSDbContext(options);
            var product = new Product
            {
                ProductName      = "Test Product",
                ShortDescription = "Test Product",
            };

            context.Products.Add(product);
            await context.SaveChangesAsync();

            var mockInventoryService = new Mock <IInventoryService>();
            var service = new ProductsService(context, mockInventoryService.Object);

            var image = new ImageViewModel {
                ProductId = product.Id, Url = "https://c8.alamy.com/comp/D8RWP0/url-of-web-browser-D8RWP0.jpg"
            };
            await service.AddProductImageAsync(image);

            Assert.True(context.Images.Count() == 1);
        }
Пример #22
0
        public async Task GetProductDetails()
        {
            var options = new DbContextOptionsBuilder <WHMSDbContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;

            using var context = new WHMSDbContext(options);
            var product = new Product
            {
                ProductName      = "Test Product",
                ShortDescription = "Test Product",
                WebsitePrice     = 23,
            };

            context.Products.Add(product);
            await context.SaveChangesAsync();

            var mockInventoryService = new Mock <IInventoryService>();
            var service = new ProductsService(context, mockInventoryService.Object);

            var productFromService = service.GetProductDetails <ProductDetailsViewModel>(product.Id);

            Assert.Equal(product.ProductName, productFromService.ProductName);
            Assert.Equal(product.ShortDescription, productFromService.ShortDescription);
            Assert.Equal(product.WebsitePrice, productFromService.WebsitePrice);
        }
Пример #23
0
        public async Task ShipOrderShouldNotUpdateOrderStatusesAndInventoryWhenAlreadyShipped()
        {
            var options = new DbContextOptionsBuilder <WHMSDbContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;

            using var context = new WHMSDbContext(options);
            var warehouse = new Warehouse
            {
                Address = new Address {
                },
                Name    = "Test",
            };
            var product = new Product
            {
                ProductName = "Test Product",
            };
            var productWarehouse = new ProductWarehouse
            {
                Product               = product,
                Warehouse             = warehouse,
                AggregateQuantity     = 0,
                TotalPhysicalQuanitiy = 10,
                ReservedQuantity      = 5,
            };

            var shippingService = "FedEx";
            var carrier         = new Carrier {
                Name = shippingService
            };

            context.Carriers.Add(carrier);
            var shipping = new ShippingMethod {
                Carrier = carrier, CarrierId = carrier.Id, Name = shippingService
            };

            context.ShippingMethods.Add(shipping);
            await context.SaveChangesAsync();

            context.Warehouses.Add(warehouse);
            context.Products.Add(product);
            context.ProductWarehouses.Add(productWarehouse);

            await context.SaveChangesAsync();

            var order = new Order {
                WarehouseId = warehouse.Id, ShippingStatus = ShippingStatus.Shipped
            };

            context.Orders.Add(order);
            var orderItem = new OrderItem {
                ProductId = product.Id, Qty = 5, OrderId = order.Id, Order = order
            };

            context.OrderItems.Add(orderItem);
            await context.SaveChangesAsync();

            var mockInventoryService = new Mock <IInventoryService>();
            var service    = new ShippingService(context, mockInventoryService.Object);
            var shipMethod = new ShippingMethodInputModel {
                CarrierId = carrier.Id, Id = shipping.Id
            };
            await service.ShipOrderAsync(new Web.ViewModels.Orders.ShipOrderInputModel {
                OrderId = order.Id, ShippingMethod = shipMethod, TrackingNumber = "test"
            });

            mockInventoryService.Verify(x => x.RecalculateInventoryAfterShippingAsync(It.IsAny <int>(), It.IsAny <int>()), Times.Never);
        }