Question: Write a Console App solution named Module7 with project EnumerationTypes (you may need to rename it from Module7) Your project enumerates the six flowers (tulip,
Write a Console App solution named Module7 with project EnumerationTypes (you may need to rename it from Module7)
Your project enumerates the six flowers (tulip, carnation, rose, peony, petunia, and daisy) and the days of the week. Call the enumeration type Flower and WaterDays, respectively.
Write a method GardenPlan() that accepts the Flower enum variable as a parameter and uses case/switch statement to create a local string variable you will return for printing in the main method. This return value will assign the watering scheduling. You will use WaterDays enum in the method to build the string. The method then returns a concatenated string of the flower name "needs watering " watering days. See output below, this also gives you the watering schedule to code.
Excepted Output: |
A carnation needs watering on the Weekend A peony needs watering on Wednesday, Saturday A petunia needs watering on Monday, Friday A daisy needs watering on Saturday A rose needs watering on Tuesday, Friday A tulip needs watering on Monday, Thursday |
In the Main() method, display each of the 6 rows by calling method gardenPlan() and printing to the console. No need for a variable, use the enum Flower here.
Download the UnitTest1.cs file to use and write the two Unit Tests Don't forget using Module 7 and make your class Program to be public class Program.
Unit Test Download:
using System; using Xunit;
namespace XUnitTestModule7 { public class UnitTest1 { [Fact] public void TestGradenPlanCarnationWateringDays() { // ARRANGE Module7.Flower flower = Module7.Flower.carnation; string expected = "A carnation needs watering on the Weekend"; string actual; // ACT actual = Module7.Program.GardenPlan(flower); // ASSERT Assert.Equal(expected, actual); }
[Fact] public void TestGradenPlanPeonyWateringDays() { // ARRANGE Module7.Flower flower = Module7.Flower.peony; string expected = "A peony needs watering on Wednesday, Saturday"; string actual; // ACT actual = Module7.Program.GardenPlan(flower); // ASSERT Assert.Equal(expected, actual); }
[Fact] public void TestGradenPlanPetuniaWateringDays() { // ARRANGE Module7.Flower flower = Module7.Flower.petunia; string expected = "A petunia needs watering on Monday, Friday"; string actual; // ACT actual = Module7.Program.GardenPlan(flower); // ASSERT Assert.Equal(expected, actual); }
[Fact] public void TestGradenPlanDaisyWateringDays() { // ARRANGE Module7.Flower flower = Module7.Flower.daisy; string expected = "A daisy needs watering on Saturday"; string actual; // ACT actual = Module7.Program.GardenPlan(flower); // ASSERT Assert.Equal(expected, actual); }
[Fact] public void TestGradenPlanRoseWateringDays() { // ARRANGE // ACT // ASSERT throw new NotImplementedException("Not implemented."); }
[Fact] public void TestGradenPlanTulipWateringDays() { // ARRANGE // ACT // ASSERT throw new NotImplementedException("Not implemented."); } } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
