コード例 #1
0
 private void btnSetDay_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         menagerie.SetDay();
         RefreshLb();
         DisplayMessage("The day has come");
     }
     catch (IsDayException)
     {
         DisplayMessage("It is already day");
     }
 }
コード例 #2
0
        public void SetDayTest()
        {
            var menagerie = new Menagerie();

            menagerie.SetNight();

            var animal1 = new Wolf("test", 1);
            var animal2 = new Bear("test2", 2);

            animal2.NightNight();

            menagerie.AddAnimal(animal1);
            menagerie.AddAnimal(animal2);

            menagerie.SetDay();

            Assert.IsFalse(animal1.IsSleeping);
            Assert.IsFalse(animal2.IsSleeping);
        }
コード例 #3
0
        public void SetDayInvalidTest()
        {
            var menagerie = new Menagerie();

            Assert.ThrowsException <IsDayException>(() => menagerie.SetDay());
        }