public void CheckIntegrity() { CellBasedSim sim = new CellBasedSim(TestUtils.RandomSeed); sim.GenerateNew(24, 10, 10, 500, 3000, 0.1f, TestUtils.RandomSeed); sim.DoStepReference(); bool result = sim.CheckIntegrity(); Assert.IsTrue(result); }
/// <summary> /// Checks if current simulation state is the same as expected state /// </summary> /// <param name="simCurrent">Simulation</param> /// <param name="simType">Simulation type</param> /// <param name="stateName">State name</param> public static void AssertSimulationWithState(SimulationBase simCurrent, SimulationType simType, string stateName) { SimulationBase simExpected = SimulationBase.LoadFromStream(OpenStateFromResources(stateName), RandomSeed); Assert.AreEqual(simType, simExpected.CurrentType); Assert.AreEqual(simExpected.CurrentType, simCurrent.CurrentType); Assert.IsTrue(simExpected.IsReady); Assert.AreEqual(simExpected.IsReady, simCurrent.IsReady); Assert.AreEqual(simExpected.CurrentStep, simCurrent.CurrentStep); Assert.AreEqual(simExpected.GetType(), simCurrent.GetType()); switch (simType) { case SimulationType.CellBased: { CellBasedSim simExpected2 = simExpected as CellBasedSim; Assert.IsNotNull(simExpected2); CellBasedSim simCurrent2 = simCurrent as CellBasedSim; Assert.IsNotNull(simCurrent2); Assert.IsTrue(simCurrent2.CheckIntegrity()); break; } case SimulationType.CarFollowing: { CarFollowingSim simExpected2 = simExpected as CarFollowingSim; Assert.IsNotNull(simExpected2); CarFollowingSim simCurrent2 = simCurrent as CarFollowingSim; Assert.IsNotNull(simCurrent2); Assert.AreEqual(simExpected2.Current.CarsPerCell, simCurrent2.Current.CarsPerCell); Assert.IsTrue(simCurrent2.CheckIntegrity()); break; } default: Assert.Fail("Unknown simulation type"); break; } }