public async Task TestAddProductAsync() { // Arrange var dbContext = DbContextMocker.GetStoreDbContext(nameof(TestAddProductAsync)); var service = ServiceMocker.GetWarehouseService(dbContext); var controller = new WarehouseController(service, null); var request = new AddProductRequest { ProductID = 100, ProductName = "Coca Cola Zero 24 fl Oz Bottle Special Edition", ProductDescription = "Enjoy Coca-Cola’s crisp.", Price = 2.15m }; controller.MockControllerContext(); // Act var response = await controller.AddProductAsync(request) as ObjectResult; var value = response.Value as ISingleResponse <AddProductRequest>; service.Dispose(); // Assert Assert.False(value?.DidError); }
public async Task TestLikeProductAsync() { // Arrange var dbContext = DbContextMocker.GetStoreDbContext(nameof(TestLikeProductAsync)); var service = ServiceMocker.GetWarehouseService(dbContext); var controller = new WarehouseController(service, null); var id = 1000; controller.MockControllerContext(); // Act var response = await controller.LikeProductAsync(id) as ObjectResult; var value = response.Value as IResponse; service.Dispose(); // Assert Assert.False(value?.DidError); }