private void Update() { Console.WriteLine("Enter Name to update: "); string name = Console.ReadLine(); Tree tree = treeBusiness.GetTreeByName(name); if (tree != null) { Console.WriteLine("Enter name: "); tree.Name = Console.ReadLine(); Console.WriteLine("Enter type: "); tree.Type = Console.ReadLine(); Console.WriteLine("Enter height: "); tree.Height = decimal.Parse(Console.ReadLine()); Console.WriteLine("Enter stem diameter: "); tree.StemDiameter = decimal.Parse(Console.ReadLine()); Console.WriteLine("Enter seasons Id: "); Console.WriteLine("(1-spring, 2-summer, 3-autumn, 4-winter)"); tree.SeasonsId = int.Parse(Console.ReadLine()); treeBusiness.Update(tree); Console.WriteLine("The tree was updated successfully!"); } else { Console.WriteLine("Tree not found!"); } }
public void Update_Tree() { var mockContext = new Mock <GardenContext>();; var treeBusiness = new TreeBusiness(); var Tree = new Tree() { Name = "Tree1" }; try { treeBusiness.Update(Tree); } catch { mockContext.Verify(m => m.Entry(It.IsAny <Tree>()), Times.Once()); } }