public void Delete_SuccessfullyDeleted_ShouldReturnOk() { _service.Setup(s => s.DeleteRecipe(1)).Returns(true); var result = _controller.Delete(1); Assert.That(result, Is.TypeOf <OkResult>()); }
public void Delete_ShouldReturnNoContent_WhenDeletingExistingRecipe() { var recipe = TestDataRepository.BuildRecipe(); _repository.Setup(x => x.FindById(recipe.ID.ToString())).Returns(recipe); var result = _recipesController.Delete(recipe.ID.ToString()); var res = result as NoContentResult; Assert.IsNotNull(res); }
public async void CanDeleteRecipe() { DbContextOptions <CookBookDbContext> options = new DbContextOptionsBuilder <CookBookDbContext>().UseInMemoryDatabase("CanDeleteRecipe").Options; using (CookBookDbContext context = new CookBookDbContext(options)) { //Arrange Recipes recipe = new Recipes(); recipe.ID = 1; recipe.Name = "Sketti n Ketchup"; Recipes recipe2 = new Recipes(); recipe2.ID = 2; recipe2.Name = "Bread n Water"; //Act RecipesController recipesController = new RecipesController(context, configuration); await recipesController.Post(recipe); await recipesController.Post(recipe2); await recipesController.Delete(recipe.ID); var result = context.Recipes.FirstOrDefault(c => c.ID == recipe.ID); //Assert Assert.Null(result); } }
public async Task Delete() { var controller = new RecipesController(_service.Object); var result = await controller.Delete(_recipe.Id); Assert.IsType <OkResult>(result); }