public void Add_Cactus() { var mockSet = new Mock <DbSet <Cactus> >(); var cactus = new Cactus(); var mockContext = new Mock <GardenContext>(); mockContext.Setup(m => m.Cactuses).Returns(mockSet.Object); var business = new CactusBusiness(mockContext.Object); business.Add(cactus); mockSet.Verify(m => m.Add(It.IsAny <Cactus>()), Times.Once()); mockContext.Verify(m => m.SaveChanges(), Times.Once()); }
private void Add() { Cactus cactus = new Cactus(); Console.WriteLine("Enter name: "); cactus.Name = Console.ReadLine(); Console.WriteLine("Enter height: "); cactus.Height = decimal.Parse(Console.ReadLine()); Console.WriteLine("Enter thorns: "); cactus.Thorns = Console.ReadLine(); Console.WriteLine("Enter seasons Id: "); Console.WriteLine("(1-spring, 2-summer, 3-autumn, 4-winter)"); cactus.SeasonsId = int.Parse(Console.ReadLine()); cactusBusiness.Add(cactus); Console.WriteLine("The cactus was successfully added!"); }