public void GetRecipe_WithNonExistingId_ReturnsNull() { //Arrange this.DbContext.Recipes.Add(new Recipe() { Id = 1, Title = "First recipe" }); this.DbContext.SaveChanges(); var service = new UserRecipeService(this.DbContext, this.Mapper, null); //Act var recipe = service.GetRecipe(200); //Assert Assert.IsNull(recipe); }
public void GetRecipe_WithExistingId_ReturnsRecipe() { //Arrange this.DbContext.Recipes.Add(new Recipe() { Id = 1, Title = "First recipe" }); this.DbContext.SaveChanges(); var service = new UserRecipeService(this.DbContext, this.Mapper, null); //Act var recipe = service.GetRecipe(1); //Assert Assert.IsNotNull(recipe); Assert.AreEqual(1, recipe.Id); Assert.AreEqual("First recipe", recipe.Title); }