Exemple #1
0
 public void Uppg7_TestAddFamilyMemberWithNegativeAge()
 {
     string errMsg = "";
     var uppg7 = new Uppgift7();
     try
     {
         uppg7.AddFamilyMember(-1);
     }
     catch (Exception e)
     {
         errMsg = e.Message;
     }
     Assert.AreEqual("Ogiltig ålder", errMsg);
 }
Exemple #2
0
 public void Uppg7_TestAddFamilyMemberWithAgeOver100()
 {
     string errMsg = "";
     var uppg7 = new Uppgift7();
     try
     {
         uppg7.AddFamilyMember(101);
     }
     catch (Exception e)
     {
         errMsg = e.Message;
     }
     Assert.AreEqual("Nöjesparkens max tillåtna ålder är 100", errMsg);
 }
Exemple #3
0
 static void Main(string[] args)
 {
     while(true)
     {
         Console.Clear();
         Console.WriteLine("Hej, välj uppgift:");
         Console.WriteLine("1. Uppgift 1");
         Console.WriteLine("7. Uppgift 7");
         int val;
         int.TryParse(Console.ReadLine(), out val);
         if(val == 1)
         {
             var uppg1 = new Uppgift1();
             uppg1.RunConsole();
         }
         else if(val == 7)
         {
             var uppg7 = new Uppgift7();
             uppg7.RunConsole();
         }
     }
 }
Exemple #4
0
 static void Main(string[] args)
 {
     while (true)
     {
         Console.Clear();
         Console.WriteLine("Hej, välj uppgift:");
         Console.WriteLine("1. Uppgift 1");
         Console.WriteLine("7. Uppgift 7");
         int val;
         int.TryParse(Console.ReadLine(), out val);
         if (val == 1)
         {
             var uppg1 = new Uppgift1();
             uppg1.RunConsole();
         }
         else if (val == 7)
         {
             var uppg7 = new Uppgift7();
             uppg7.RunConsole();
         }
     }
 }
Exemple #5
0
        public void Uppg7_TestTotalCostForFamilyOnSunday()
        {
            var uppg7 = new Uppgift7();

            int expectedTotalCost = 0;

            uppg7.AddFamilyMember(57);
            expectedTotalCost += 200;
            uppg7.AddFamilyMember(55);
            expectedTotalCost += 200;
            uppg7.AddFamilyMember(16);
            expectedTotalCost += 200;
            uppg7.AddFamilyMember(12);
            expectedTotalCost += 100;
            uppg7.AddFamilyMember(4);
            expectedTotalCost += 0;

            // Sätt veckodagen till helgdag
            uppg7.IsWeekend = true;

            Assert.AreEqual(expectedTotalCost, uppg7.GetTotalPrice());
        }
Exemple #6
0
        public void Uppg7_TestTotalCostForFamilyOnWednesday()
        {
            var uppg7 = new Uppgift7();

            int expectedTotalCost = 0;

            uppg7.AddFamilyMember(57);
            expectedTotalCost += 100;
            uppg7.AddFamilyMember(55);
            expectedTotalCost += 100;
            uppg7.AddFamilyMember(16);
            expectedTotalCost += 100;
            uppg7.AddFamilyMember(12);
            expectedTotalCost += 50;
            uppg7.AddFamilyMember(4);
            expectedTotalCost += 0;

            // Non Weekend
            uppg7.IsWeekend = false;

            Assert.AreEqual(expectedTotalCost, uppg7.GetTotalPrice());
        }