public void ConstructorTest()
        {
            SetUp();

            Assert.Equal(ESimulationStage.AfterInfectedCalculation, _component.SimulationStages);
            Assert.Equal(HOURS_PER_YEAR/DEFAULT_HOURS_PER_TICK, _component.TicksPerYear);
            Assert.Equal(DEFAULT_AGE_LIMIT, _component.AgeLimit);

            int ageLimit = RANDOM.Next(125);                              // |f| Just to stay realistic :D
            int simulationIntervall = RANDOM.Next(1, HOURS_PER_YEAR);     // |f| Do not need to test outside of 1-8544

            _component = new AgeingComponent(ageLimit);
            _component.SetSimulationIntervall(simulationIntervall);

            Assert.Equal(HOURS_PER_YEAR/simulationIntervall, _component.TicksPerYear);
            Assert.Equal(ageLimit, _component.AgeLimit);
        }
 private void SetUp()
 {
     _component = new AgeingComponent(DEFAULT_AGE_LIMIT);
     _component.SetSimulationIntervall(DEFAULT_HOURS_PER_TICK);
 }
예제 #3
0
        private SimulationComponent[] GetSimComponents(EComponentTag[] tags)
        {
            SimulationComponent[] comps = new SimulationComponent[tags.Length];

            for (int i = 0; i < tags.Length; ++i)
            {
                SimulationComponent c = null; // | dj | not the most secure way but it should work.
                switch (tags[i])
                {
                    case EComponentTag.AgeingComponent:
                        c = new AgeingComponent(110);
                        break;
                    case EComponentTag.InfectionComponent:
                        c = new InfectionComponent();
                        break;
                    case EComponentTag.DiseaseTickComponent:
                        c = new DiseaseTickComponent();
                        break;
                    case EComponentTag.DiseaseDeathComponent:
                        c = new DiseaseDeathComponent();
                        break;
                    case EComponentTag.DiseaseHealingComponent:
                        c = new DiseaseHealingComponent();
                        break;
                    case EComponentTag.MindsetComponent:
                        c = new MindsetComponent();
                        break;
                    case EComponentTag.MovementComponent:
                        c = new MovementComponent();
                        break;
                }
                comps[i] = c;
            }

            // if no (diseasetick-)component given: debug-infection
            //if (comps.Length == 0) comps = new SimulationComponent[1] { new DebugInfectionComponent() };
            if (!comps.Any(x => x is InfectionComponent))
            {
                SimulationComponent[] temp = new SimulationComponent[comps.Length + 1];
                comps.CopyToOtherArray(temp);
                temp[comps.Length] = new DebugInfectionComponent();
                comps = temp;
                temp = null;
            }
            return comps;
        }