Beispiel #1
0
        public void Add_Flower()
        {
            var mockSet     = new Mock <DbSet <Flower> >();
            var flower      = new Flower();
            var mockContext = new Mock <GardenContext>();

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

            var business = new FlowerBusiness(mockContext.Object);

            business.Add(flower);

            mockSet.Verify(m => m.Add(It.IsAny <Flower>()), Times.Once());
            mockContext.Verify(m => m.SaveChanges(), Times.Once());
        }
        private void Add()
        {
            Flower flower = new Flower();

            Console.WriteLine("Enter name: ");
            flower.Name = Console.ReadLine();
            Console.WriteLine("Enter color: ");
            flower.Color = Console.ReadLine();
            Console.WriteLine("Enter life expectancy: ");
            flower.LifeExpectancy = Console.ReadLine();
            Console.WriteLine("Enter seasons Id: ");
            Console.WriteLine("(1-spring, 2-summer, 3-autumn, 4-winter)");
            flower.SeasonsId = int.Parse(Console.ReadLine());
            flowerBusiness.Add(flower);
            Console.WriteLine("The flower was successfully added!");
        }