Exemple #1
0
        private void Add()
        {
            Grass grass = new Grass();

            Console.WriteLine("Enter name: ");
            grass.Name = Console.ReadLine();
            Console.WriteLine("Enter height: ");
            grass.Height = decimal.Parse(Console.ReadLine());
            Console.WriteLine("Enter seasons Id: ");
            Console.WriteLine("(1-spring, 2-summer, 3-autumn, 4-winter)");
            grass.SeasonsId = int.Parse(Console.ReadLine());
            grassBusiness.Add(grass);
            Console.WriteLine("The grass was successfully added!");
        }
        public void Add_Grass()
        {
            var mockSet     = new Mock <DbSet <Grass> >();
            var grass       = new Grass();
            var mockContext = new Mock <GardenContext>();

            mockContext.Setup(m => m.Grasses).Returns(mockSet.Object);

            var business = new GrassBusiness(mockContext.Object);

            business.Add(grass);

            mockSet.Verify(m => m.Add(It.IsAny <Grass>()), Times.Once());
            mockContext.Verify(m => m.SaveChanges(), Times.Once());
        }