Exemple #1
0
        public PlantControllerTest()
        {
            //Mock Setup
            plantMock  = new Mock <ImyPlant>();
            plantsMock = new List <ImyPlant> {
                plantMock.Object
            };
            addPlantMock    = new Mock <IAddPlant>();
            updatePlantMock = new Mock <IUpdatePlant>();
            mockRepo        = new Mock <IRepoWrapper>();
            plant           = new myPlant();
            plants          = new List <myPlant>();
            var allPlants = GetPlants();


            //Sample Models
            addPlant = new AddPlant {
                ID = 1, Name = "Radish", DatePlanted = "29.10.2019", DateLastWatered = "30.10.2019", Garden = "Windowsill"
            };
            updatePlant = new UpdatePlant {
                ID = 1, Name = "Radish", DatePlanted = "29.10.2019", DateLastWatered = "30.10.2019", Garden = "Windowsill"
            };

            //Controller Setup
            var plantResultMock = new Mock <IActionResult>();

            plantController = new PlantController(mockRepo.Object);
        }
Exemple #2
0
        public static void Main()
        {
            Console.WriteLine("--------------");
            Console.WriteLine("Welcome to my plant game");
            Console.WriteLine("press 'enter' to start taking care of your own plant");
            Console.WriteLine("what would you like to name your plant?");
            string plantName = Console.ReadLine();

            Console.WriteLine("Which of these options would you like to do?");
            Console.WriteLine("-------------------");
            Console.WriteLine("type 1 if you want to  water your plant. \ntype 2 if you want to feed your plant. \ntype 3 if you want  your to have some SUN.");
            string  listen   = Console.ReadLine();
            myPlant NewPlant = new myPlant(plantName, 50, 30, 10);

            switch (listen)
            {
            case "1":
                NewPlant.Water();
                break;

            case "2":
                NewPlant.Feed();
                break;

            case "3":
                NewPlant.giveSunshine();
                break;

            default:
                Console.WriteLine("Please enter a valid number");
                break;
            }
            if (NewPlant)
            {
                int giveWater = NewPlant.getWater();
            }
            int giveFood = NewPlant.getfood();
            int giveSun  = NewPlant.getgiveSunshine();

            Console.WriteLine("your name is " + plantName + "\nyour initial water level is: '50' \nyour inital food level is '30' \nyour inital sun level is '10' ");
            Console.WriteLine("-----------------");
            Console.WriteLine("\nyour name is: " + plantName + "\nyour new water level is: " + giveWater + "\nyour new food level is: " + giveFood + "\nyour newsun level is: " + giveSun + " ");
            // instance of the class which contains the plants name, inital water level, inital food level, and initial sun level.
        }
Exemple #3
0
        public IActionResult Create(AddPlantBindingModel bindingModel)
        {
            var plantToCreate = new myPlant
            {
                Name            = bindingModel.Name,
                DatePlanted     = bindingModel.DatePlanted,
                DateLastWatered = bindingModel.DateLastWatered,
                Garden          = bindingModel.Garden
            };

            var gardenToCreate = new myGarden
            {
                Name = plantToCreate.Garden
            };

            _repo.Gardens.Create(gardenToCreate);


            _repo.Plants.Create(plantToCreate);

            _repo.Save();
            return(RedirectToAction("Plant"));
        }
Exemple #4
0
 public IActionResult Edit(myPlant plant, int id)
 {
     _repo.Plants.Edit(plant);
     _repo.Save();
     return(RedirectToAction("Plant"));
 }