Exemplo n.º 1
0
        public void SnapshotTest()
        {
            int     startPopulation = 10;
            Species fox             = new Species("fox", startPopulation, 3, 1, 200);

            Ecosystem.GetInstance().AddSpecies(fox);
            Memento.Save();

            IMathModel model = new LogisticModel();

            model.Recount();

            Assert.AreEqual(29, fox.Population);

            Memento.Restore();
            Assert.AreEqual(startPopulation, Ecosystem.GetInstance().Species[0].Population);

            Ecosystem.GetInstance().Species.Clear();
            History.GetInstance().Data.Clear();
        }
Exemplo n.º 2
0
        public void LogisticModelTest_Extinction()
        {
            //Init data
            int currentPopulation  = 10;
            int birth              = 1;
            int death              = 10;
            int ecoCapacity        = 200;
            int expectedpopulation = 0;

            //Actions
            Species fox = new Species("fox", currentPopulation, birth, death, ecoCapacity);

            Ecosystem.GetInstance().AddSpecies(fox);
            LogisticModel lm = new LogisticModel();

            lm.Recount();

            //Check
            Assert.AreEqual(expectedpopulation, fox.Population);

            Ecosystem.GetInstance().Species.Clear();
            History.GetInstance().Data.Clear();
        }