コード例 #1
0
        public void Uppg7_TestAddFamilyMemberWithAgeZero()
        {
            string errMsg = "";
            var    uppg7  = new Uppgift7();

            try
            {
                uppg7.AddFamilyMember(0);
            }
            catch (Exception e)
            {
                errMsg = e.Message;
            }
            Assert.AreEqual("Ogiltig ålder", errMsg);
        }
コード例 #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);
        }
コード例 #3
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());
        }
コード例 #4
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());
        }