public async void DeleteProductByIdTest_Return_OkResult() { //Arrange var productRepo = new ProductSessionRepository(DbContext); var productService = new ProductServices(productRepo); var controller = new ProductsController(productService, productRepo); var productId = 78; //Act var data = await controller.DeleteProduct(productId); //Assert _ = Assert.IsType<OkResult>(data); }
public async void GetSumStrockPrice_Return_SumPriceInStock() { //Arrange var productRepo = new ProductSessionRepository(DbContext); var productService = new ProductServices(productRepo); var productId = 4; decimal expectedResult = 1166; //Act var actual = await productService.GetSumStrockPrice(productId); //Assert Assert.Equal(expectedResult, actual); }
public async void GetProductByIdTest_Return_Product() { //Arrange var productRepo = new ProductSessionRepository(DbContext); var productService = new ProductServices(productRepo); var productId = 5; string expectedName = "Chef Anton's Gumbo Mix _ Test"; //Act var actual = await productService.GetProduct(productId); //Assert Assert.Equal(expectedName, actual.ProductName); }
public async void GetProductByIdTest_Return_OkResult() { //Arrange var productRepo = new ProductSessionRepository(DbContext); var productService = new ProductServices(productRepo); var controller = new ProductsController(productService, productRepo); var productId = 5; string expectedName = "Chef Anton's Gumbo Mix _ Test"; //Act var data = await controller.GetProduct(productId); //Assert var okResult = Assert.IsType<OkObjectResult>(data.Result); var product = Assert.IsType<Product>(okResult.Value); Assert.Equal(expectedName, product.ProductName); }
public async Task GetProductById_TestAsync() { //Arrange //var dbContext = CreateDbContext(); var productSessionRepository = new ProductSessionRepository(DbContext); int productId = 5; string productName = "Chef Anton's Gumbo Mix _ Test"; //Act var result = await productSessionRepository.GetById(productId); //Assert Assert.Equal(productId, result.ProductId); Assert.Equal(productName, result.ProductName); //Clean up DbContext.Dispose(); }
public async Task DeleteProduct_TestAsync() { //Arrange //var dbContext = CreateDbContext(); var productSessionRepository = new ProductSessionRepository(DbContext); int productId = 78; //Act await productSessionRepository.Delete(productId); var result = await productSessionRepository.GetById(productId); //Assert Assert.True(result == null); //Clean up DbContext.Dispose(); }