public void Add_Shrub() { var mockSet = new Mock <DbSet <Shrub> >(); var shrub = new Shrub(); var mockContext = new Mock <GardenContext>(); mockContext.Setup(m => m.Shrubs).Returns(mockSet.Object); var business = new ShrubBusiness(mockContext.Object); business.Add(shrub); mockSet.Verify(m => m.Add(It.IsAny <Shrub>()), Times.Once()); mockContext.Verify(m => m.SaveChanges(), Times.Once()); }
private void Add() { Shrub shrub = new Shrub(); Console.WriteLine("Enter name: "); shrub.Name = Console.ReadLine(); Console.WriteLine("Enter type: "); shrub.Type = Console.ReadLine(); Console.WriteLine("Enter height: "); shrub.Height = decimal.Parse(Console.ReadLine()); Console.WriteLine("Enter life expectancy: "); shrub.LifeExpectancy = Console.ReadLine(); Console.WriteLine("Enter seasons Id: "); Console.WriteLine("(1-spring, 2-summer, 3-autumn, 4-winter)"); shrub.SeasonsId = int.Parse(Console.ReadLine()); shrubBusiness.Add(shrub); Console.WriteLine("The shrub was successfully added!"); }