Beispiel #1
0
        public ActionResult Results(int score)
        {
            AllergyScore allergy = new AllergyScore();

            allergy.Score = allergy.GetAllergyScore(score);
            return(View(allergy));
        }
Beispiel #2
0
        public void CheckAllergies_IfInputIs25_eggsstrawberriestomatoes()
        {
            AllergyScore testAllergyScore = new AllergyScore();

            CollectionAssert.AreEqual(new List <string> {
                "eggs", "strawberries", "tomatoes"
            }, testAllergyScore.CheckAllergies(25));
        }
Beispiel #3
0
        public void CheckAllergies_IfInputIs3_eggspeanuts()
        {
            AllergyScore testAllergyScore = new AllergyScore();

            CollectionAssert.AreEqual(new List <string> {
                "eggs", "peanuts"
            }, testAllergyScore.CheckAllergies(3));
        }
Beispiel #4
0
        public void CheckAllergies_IfInputIs4_shellfish()
        {
            AllergyScore testAllergyScore = new AllergyScore();

            CollectionAssert.AreEqual(new List <string> {
                "shellfish"
            }, testAllergyScore.CheckAllergies(4));
        }
Beispiel #5
0
        public void WhichAllergen_ForHigherScore_ReturnAllergen()
        {
            int           score    = 9;
            AllergyScore  newScore = new AllergyScore(score);
            List <string> results  = newScore.FindAllergen();
            string        result   = results[0];

            Assert.Equal(true, result == "strawberries");
        }
Beispiel #6
0
        public void WhichAllergen_ForExactScore_ReturnAllergen()
        {
            int           score    = 8;
            AllergyScore  newScore = new AllergyScore(score);
            List <string> results  = newScore.FindAllergen();
            string        result   = results[0];

            Console.WriteLine(result);
            Assert.Equal(true, result == "strawberries");
        }
Beispiel #7
0
        public void WhichAllergen_ForHigherScore_ReturnAllergenWithRemainder()
        {
            int           score    = 9;
            AllergyScore  newScore = new AllergyScore(score);
            List <string> results  = newScore.FindAllergen();
            string        result   = results[0];

            if (newScore.GetScore() > 0)
            {
                result = result + ", " + newScore.GetScore().ToString();
            }
            // remainder of 1 removed upon completion of following spec(multiple allergens)
            Assert.Equal(false, result == "strawberries, 1");
        }
Beispiel #8
0
        public static void Main()
        {
            AllergyScore allergyCalculator = new AllergyScore();

            Console.WriteLine("Enter your allergy score, and I will tell you what you are allergic to: ");
            int           userNum       = int.Parse(Console.ReadLine());
            List <string> userAllergies = allergyCalculator.CheckAllergies(userNum);

            Console.WriteLine("Looks like you're allergic to: ");
            foreach (string allergen in userAllergies)
            {
                Console.WriteLine(allergen);
            }
            Continue();
        }
        public static void Main()
        {
            bool keepRunning;

            do
            {
                Console.WriteLine("Enter your allergy score: ");
                int          scoreInput   = int.Parse(Console.ReadLine());
                AllergyScore allergyScore = new AllergyScore(scoreInput);

                allergyScore.PrintAllergies();

                Console.WriteLine("Go again? (y/n)");
                keepRunning = Console.ReadLine() == "y";
                Console.WriteLine();
            } while (keepRunning);
        }
Beispiel #10
0
        public void WhichAllergen_ForLargeScore_ReturnAllAllergens()
        {
            int           score    = 9;
            AllergyScore  newScore = new AllergyScore(score);
            List <string> results  = newScore.FindAllergen();
            string        result   = results[0];

            if (results.Count > 1)
            {
                for (var idx = 1; idx < results.Count; idx++)
                {
                    result = result + ", " + results[idx];
                }
            }
            Console.WriteLine("result string: " + result);
            Assert.Equal(true, result == "strawberries, eggs");
        }
 public List <Allergen> List() =>
 (from Allergen allergen in Enum.GetValues(typeof(Allergen))
      where AllergyScore.HasFlag(allergen)
  select allergen).ToList();