private static Product CreateDummyProductToDatabase() { var dummyProduct = DummyProduct.Product(); ProductTestContext.DbContext.Product.Add(dummyProduct); ProductTestContext.DbContext.SaveChanges(); return(dummyProduct); }
public void UpdateProduct_TryToUpdateProductNotExistInDatabase_ReturnNull() { //Arrange var dummyProduct = DummyProduct.Product(); //Act var updateNullProduct = ProductRepository.UpdateProduct(dummyProduct).Result; //Assert Assert.IsNull(updateNullProduct); }
public void CreateNewProduct_CreatingNewProduct_ReturnCreatedNewProduct() { //Arrange var dummyProduct = DummyProduct.Product(); //Act var newProduct = ProductRepository.CreateProductAsync(dummyProduct).Result; //Assert Assert.AreEqual(dummyProduct, newProduct); DeleteDummyProductFromDatabase(dummyProduct); }
public void CreateProdut_CreatingExistingProductInDatabase_ReturnNull() { //Arrange var dummyProduct1 = DummyProduct.Product(); var dummyProduct2 = dummyProduct1; //Act var reCreateProduct1 = ProductRepository.CreateProductAsync(dummyProduct1).Result; var reCreateProduct2 = ProductRepository.CreateProductAsync(dummyProduct2).Result; //Assert Assert.AreEqual(reCreateProduct2, null); }