예제 #1
0
        public void ChangeSeason()
        {
            //arrange
            while (NatureEnvironment.CurrentSeason != Season.Winter)
            {
                NatureEnvironment.ChangeSeason();
            }

            //act
            NatureEnvironment.ChangeSeason();

            //assert
            Assert.AreEqual(Season.Spring, NatureEnvironment.CurrentSeason);
        }
예제 #2
0
        public void InSummerGreenAndShapely()
        {
            //arrange
            IForest testForest = new Forest();

            testForest.AddTree(new FirTree());

            //act
            NatureEnvironment.ChangeSeason();
            NatureEnvironment.ChangeSeason();

            //assert
            Assert.AreEqual(Season.Summer, NatureEnvironment.CurrentSeason);
            Assert.AreEqual(TreeShape.Shapely, testForest.Trees.LastOrDefault(x => x is FirTree).Shape);
            Assert.AreEqual(TreeColor.Green, testForest.Trees.LastOrDefault(x => x is FirTree).Color);
        }
예제 #3
0
        public void ChangeSeasonOneYear()
        {
            //arrange
            while (NatureEnvironment.CurrentSeason != Season.Winter)
            {
                NatureEnvironment.ChangeSeason();
            }
            Season seasonYearAgo = NatureEnvironment.CurrentSeason;

            //act
            NatureEnvironment.ChangeSeason();
            NatureEnvironment.ChangeSeason();
            NatureEnvironment.ChangeSeason();
            NatureEnvironment.ChangeSeason();

            //assert
            Assert.AreEqual(seasonYearAgo, NatureEnvironment.CurrentSeason);
        }
예제 #4
0
        public void AllUseCase()
        {
            IForest testForest = new Forest();

            testForest.AddTree(new FirTree());
            while (NatureEnvironment.CurrentSeason != Season.Winter)
            {
                NatureEnvironment.ChangeSeason();
            }

            Assert.AreEqual(1, testForest.TreeCount);                                                    // В лесу родилась
            Assert.IsTrue(testForest.Trees.LastOrDefault() is FirTree);                                  // ёлочка
            Assert.AreEqual(Season.Winter, NatureEnvironment.CurrentSeason);                             // Зимой
            Assert.AreEqual(TreeShape.Shapely, testForest.Trees.LastOrDefault(x => x is FirTree).Shape); // стройная
            Assert.AreEqual(TreeColor.Green, testForest.Trees.LastOrDefault(x => x is FirTree).Color);   // зеленая была

            NatureEnvironment.ChangeSeason();
            NatureEnvironment.ChangeSeason();

            Assert.AreEqual(testForest.Trees.LastOrDefault(x => x is FirTree).GrowthSpeed * 2, testForest.Trees.LastOrDefault(x => x is FirTree).Height); // В лесу она росла
            Assert.AreEqual(Season.Summer, NatureEnvironment.CurrentSeason);                                                                              // и летом
            Assert.AreEqual(TreeShape.Shapely, testForest.Trees.LastOrDefault(x => x is FirTree).Shape);                                                  // стройная
            Assert.AreEqual(TreeColor.Green, testForest.Trees.LastOrDefault(x => x is FirTree).Color);                                                    // зеленая была
        }