Beispiel #1
0
        public void FoodProductionTest()
        {
            Harvest    harvest         = new Harvest();
            Calendar   calendar        = new Calendar();
            Province   province        = new Province();
            Population startPopulation = new Population().Add(1000);

            Food food = harvest.FoodProduction(calendar, province);

            food.Rice.ShouldBe(0);

            province = province.Add(startPopulation);

            calendar.Month.ShouldBe(1);
            food = harvest.FoodProduction(calendar, province);
            food.Rice.ShouldBe(0);

            calendar = calendar.Add(4);
            food     = harvest.FoodProduction(calendar, province);
            food.Rice.ShouldBeGreaterThan(0);

            calendar = new Calendar();
            calendar.Month.ShouldBe(1);
            food = new Food();
            food.Rice.ShouldBe(0);

            for (int month = 0; month < 12; month++)
            {
                food     = food.Add(harvest.FoodProduction(calendar, province));
                calendar = calendar.Add(1);
            }

            food.Rice.ShouldBeGreaterThan(12 * province.Population.Adults);
        }
Beispiel #2
0
        public void FoodConsumptionTest()
        {
            Granary    granary         = new Granary();
            Calendar   calendar        = new Calendar();
            Province   province        = new Province();
            Population startPopulation = new Population().Add(1000);
            Food       foodStock       = new Food();

            foodStock = foodStock.Add(500);

            Food foodConsumption = granary.FoodConsumption(calendar, province);

            foodConsumption.Rice.ShouldBe(0);

            province = province.Add(startPopulation);
            province = province.Add(foodStock);

            calendar.Month.ShouldBe(1);
            foodConsumption = granary.FoodConsumption(calendar, province);
            foodConsumption.Rice.ShouldNotBe(0);
            foodConsumption.Rice.ShouldBeLessThanOrEqualTo(province.Food.Rice);

            calendar.Add(4);
            foodConsumption = granary.FoodConsumption(calendar, province);
            foodConsumption.Rice.ShouldBeGreaterThan(0);
            foodConsumption.Rice.ShouldBeLessThanOrEqualTo(province.Food.Rice);

            calendar = new Calendar();

            calendar.Month.ShouldBe(1);

            foodConsumption = new Food();

            foodConsumption.Rice.ShouldBe(0);

            foodStock = foodStock.Add(50000);
            province  = province.Add(foodStock);

            for (int month = 0; month < 12; month++)
            {
                foodConsumption = foodConsumption.Add(granary.FoodConsumption(calendar, province));
                calendar.Add(1);
            }

            foodConsumption.Rice.ShouldBeGreaterThan(12 * province.Population.Adults);
            foodConsumption.Rice.ShouldBeLessThanOrEqualTo(province.Food.Rice);
        }
Beispiel #3
0
        public void AddTest()
        {
            Population population = new Population().Add(42);
            Province   province   = new Province();

            province = province.Add(population);

            province.Population.Adults.ShouldBe(42);

            Food food = new Food();

            food = food.Add(42);

            province.Food.Rice.ShouldBe(0);

            province = province.Add(food);

            province.Food.Rice.ShouldBe(42);
        }
Beispiel #4
0
        public void TickTest()
        {
            World      world      = new World();
            Province   province   = new Province();
            Population population = new Population().Add(1000);
            Food       food       = new Food();

            food = food.Add(12000);

            province = province.Add(population);
            province = province.Add(food);

            world = world.Add(province);

            for (int month = 0; month < 12; month++)
            {
                world = world.Tick();
            }

            province = world.Provinces.Single();
            province.Population.Adults.ShouldBeGreaterThan(population.Adults);
            province.Food.Rice.ShouldBeGreaterThan(food.Rice);
        }
Beispiel #5
0
        public void DeathTest()
        {
            Starvation starvation = new Starvation();
            Province   province   = new Province();
            Food       food       = new Food();
            Population population = new Population().Add(1000);

            Population deathByStarvation = starvation.Death(province, food);

            deathByStarvation.Adults.ShouldBe(0);

            province = province.Add(population);

            deathByStarvation = starvation.Death(province, food);

            deathByStarvation.Adults.ShouldBeGreaterThan(0);
        }
        public void PopulationChangeTest()
        {
            Population   startPopulation = new Population().Add(1000);
            BirthControl birthControl    = new BirthControl();
            Calendar     calendar        = new Calendar();
            Province     province        = new Province();

            province.Add(startPopulation);

            Population populationFlow = new Population();

            for (int i = 0; i < 12; i++)
            {
                calendar.Add(1);

                populationFlow = populationFlow.Add(birthControl.PopulationFlow(calendar, province));
            }

            populationFlow.Adults.ShouldBeGreaterThan(0);
            populationFlow.Adults.ShouldBeLessThan(startPopulation.Adults);
        }