Example #1
0
                private void TestSerial2()
                {
                    StringBuilder serialized = new StringBuilder();

                    serialized.Append("dayTrackerTimestamp=5050000\n");
                    serialized.Append("dayTrackerLastTransitionType=IdlingToChasing\n");
                    serialized.Append("dayTrackerLastTransitionTimestamp=4000000\n");
                    serialized.Append("dayTrackerLastTransitionEstimatedTime=12\n");
                    serialized.Append("dayTrackerWholeDays=0;\n");
                    serialized.Append("dayTrackerDays=1;3600000;\n");
                    serialized.Append("dayTrackerDawns=2;100000;100000;\n");
                    serialized.Append("dayTrackerNights=3;100000;100000;100000;\n");
                    serialized.Append("dayTrackerDusks=4;100000;100000;100000;100000;\n");
                    Deserializer deserializer = new Deserializer(serialized.ToString());
                    DayTracker   dayTracker   = new DayTracker();

                    dayTracker.Deserialize(deserializer);

                    AssertEqual(dayTracker._timestamp, 5050000, "Wrong timestamp");
                    AssertEqual(dayTracker._lastRelevantTransition.Type, TransitionTypeEnum.IdlingToChasing, "Wrong last transition type");
                    AssertEqual(dayTracker._lastRelevantTransition.Timestamp, 4000000, "Wrong last transition timestamp");
                    AssertEqual(dayTracker._lastRelevantTransition.EstimatedTime, 12, "Wrong last transition estimated time");
                    AssertEqual(dayTracker._historicalData.WholeDayLengthEstimations.Count(), 0, "Wrong whole day historical data length");
                    AssertEqual(dayTracker._historicalData.DayLengthEstimations.Count(), 1, "Wrong whole daytime historical data length");
                    AssertEqual(dayTracker._historicalData.DayLengthEstimations[0], 3600000, "Wrong whole daytime historical data");
                    AssertEqual(dayTracker._historicalData.DuskLengthEstimations.Count(), 4, "Wrong dusk historical data length");
                    AssertEqual(dayTracker._historicalData.NightLengthEstimations.Count(), 3, "Wrong night historical data length");
                    AssertEqual(dayTracker._historicalData.DawnLengthEstimations.Count(), 2, "Wrong dawn historical data length");

                    Serializer serializer = new Serializer();

                    dayTracker.Serialize(serializer);
                    AssertEqual(serializer.GetSerializedString(), serialized.ToString(), "Wrong serialization of day tracker");
                }
Example #2
0
                private void TestSerial1()
                {
                    Deserializer deserializer = new Deserializer("");
                    DayTracker   dayTracker   = new DayTracker();

                    dayTracker.Deserialize(deserializer);

                    AssertEqual(dayTracker._timestamp, 0, "Wrong default timestamp");
                    AssertEqual(dayTracker._lastRelevantTransition, null, "Wrong default last transition");
                    AssertEqual(dayTracker._historicalData.WholeDayLengthEstimations.Count(), 0, "Wrong default whole day historical data length");
                    AssertEqual(dayTracker._historicalData.DayLengthEstimations.Count(), 0, "Wrong default whole daytime historical data length");
                    AssertEqual(dayTracker._historicalData.DuskLengthEstimations.Count(), 0, "Wrong default dusk historical data length");
                    AssertEqual(dayTracker._historicalData.NightLengthEstimations.Count(), 0, "Wrong default night historical data length");
                    AssertEqual(dayTracker._historicalData.DawnLengthEstimations.Count(), 0, "Wrong default dawn historical data length");
                }
Example #3
0
        private void Init()
        {
            // launch tests
            // TestSuite.AllTests.TestAll();
            // Initialization
            mainBatteriesManager      = new BatteryManager(battery => battery.CubeGrid == Me.CubeGrid);
            connectedBatteriesManager = new BatteryManager(battery => battery.CubeGrid != Me.CubeGrid);
            display      = new SolarDisplay("Main Base Solar LCD Panel", false);
            solarManager = new SolarManager("A");
            dayTracker   = new DayTracker();

            Deserializer deserializer = new Deserializer(Me.CustomData);

            solarManager.Deserialize(deserializer);
            dayTracker.Deserialize(deserializer);
            solarState = SolarState.Deserialize(deserializer.Get("solarState"));
        }