Example #1
0
 public Recipe Add(Recipe item)
 {
     var newRecipe = (Recipe)item.Clone();
     newRecipe.Id = !_recipes.Any() ? 1 : _recipes.Max(user => user.Id) + 1;
     _recipes.Add(newRecipe);
     return (Recipe)newRecipe.Clone();
 }
Example #2
0
 public Recipe Update(Recipe item)
 {
     var existRecipe = _recipes.SingleOrDefault(recipe => recipe.Id == item.Id);
     if (existRecipe == null)
     {
         throw new NullReferenceException();
     }
     existRecipe.Name = item.Name;
     return (Recipe)existRecipe.Clone();
 }
 public void AddTest()
 {
     var name = Guid.NewGuid().ToString();
     var NewRecipe = new Recipe
     {
         Name = name
     };
     var AddedRecipe = service.Add(NewRecipe);
     Assert.IsNotNull(AddedRecipe);
     Assert.IsTrue(AddedRecipe.Id > 0);
     Assert.AreEqual(AddedRecipe.Name, name);
 }