Beispiel #1
0
        public void SerializationBLLTest_Serialize_Deserialize_SkipInactiveEstw()
        {
            using (var settings = new SettingsScope())
            {
                settings.EstwTimeout       = 30;
                settings.LoadInactiveEstws = false;
                string Filename = "test.leibit";

                var Data = ExpectedValuesOfSerializationBLLTest.Serialize_Deserialize();
                Data.Area.ESTWs.Single(e => e.Id == "TREH").IsLoaded      = true;
                Data.Area.ESTWs.Single(e => e.Id == "TREH").LastUpdatedOn = DateTime.Now.AddSeconds(-40);

                var SaveResult = BLL.Save(Filename, Data);
                DefaultChecks.IsOperationSucceeded(SaveResult);

                SerializationContainer Actual;

                using (var scope = new ESTWTestDataScope(BLL))
                {
                    var OpenResult = BLL.Open(Filename);
                    DefaultChecks.IsOperationSucceeded(OpenResult);
                    Actual = OpenResult.Result;
                }

                var Expected = ExpectedValuesOfSerializationBLLTest.Serialize_Deserialize();
                AreaComparer.Instance.Compare(Expected.Area, Actual.Area);
                AreaComparer.CompareDictionary(Expected.Area.LiveTrains, Actual.Area.LiveTrains, TrainInformationComparer.Instance, "LiveTrains");
            }
        }
Beispiel #2
0
        public void SerializationBLLTest_Serialize_Deserialize()
        {
            using (var settings = new SettingsScope())
            {
                settings.LoadInactiveEstws = true;
                string Filename = "test.leibit";

                var Expected = ExpectedValuesOfSerializationBLLTest.Serialize_Deserialize();

                var SaveResult = BLL.Save(Filename, Expected);
                DefaultChecks.IsOperationSucceeded(SaveResult);

                SerializationContainer Actual;

                using (var scope = new ESTWTestDataScope(BLL))
                {
                    var OpenResult = BLL.Open(Filename);
                    DefaultChecks.IsOperationSucceeded(OpenResult);
                    Actual = OpenResult.Result;
                }

                AreaComparer.Instance.Compare(Expected.Area, Actual.Area);
                AreaComparer.CompareDictionary(Expected.Area.LiveTrains, Actual.Area.LiveTrains, TrainInformationComparer.Instance, "LiveTrains");
            }
        }
Beispiel #3
0
        public void InitializationBLLTest_LoadESTW()
        {
            using (var scope = new ESTWTestDataScope(BLL))
            {
                var Area = new Area("myTestArea", "Testland");
                var Estw = new ESTW("TTST", "Testdorf", "leibit_TEST.dat", Area);
                new ESTW("TREH", "Rechtsheim", "leibit_RECHTSHEI.dat", Area);
                var Expected = ExpectedValuesOfInitializationBLLTest.LoadTestdorfESTW();

                //int progress = 0;
                //bool finished = false;
                //OperationResult<bool> BllResult = null;

                //var worker = new BackgroundWorker();
                //worker.WorkerReportsProgress = true;
                //worker.ProgressChanged += (sender, e) => progress = e.ProgressPercentage;
                //worker.DoWork += (sender, e) => BllResult = BLL.LoadESTW(Estw, sender as BackgroundWorker);
                //worker.RunWorkerCompleted += (sender, e) => finished = true;
                //worker.RunWorkerAsync();

                //while (!finished) ;

                OperationResult <bool> BllResult = BLL.LoadESTW(Estw);

                DefaultChecks.IsOperationSucceeded(BllResult);
                Assert.IsTrue(BllResult.Result, "Result is false.");
                AreaComparer.Instance.Compare(Expected, Area);
                //Assert.AreEqual(100, progress);
            }
        }
Beispiel #4
0
        public void InitializationBLLTest_GetAreaInformation()
        {
            using (var scope = new ESTWTestDataScope(BLL))
            {
                var Expected  = ExpectedValuesOfInitializationBLLTest.GetAreaInformation();
                var BllResult = BLL.GetAreaInformation();

                DefaultChecks.IsOperationSucceeded(BllResult);
                DefaultChecks.HasResultValue(BllResult);

                LeibitComparer <Area> .CompareList(Expected, BllResult.Result, AreaComparer.Instance, "Result");
            }
        }
        public void InitializationBLLTest_LoadMultipleScheduleFiles()
        {
            using (var scope = new ESTWTestDataScope(BLL))
            {
                var area     = new Area("scheduleArea", "Schedules");
                var estw     = new ESTW("ST", "ScheduleTest", "leibit_ST.dat", area);
                var Expected = ExpectedValuesOfInitializationBLLTest.LoadScheduleTestESTW();

                OperationResult <bool> BllResult = BLL.LoadESTW(estw);
                DefaultChecks.IsOperationSucceeded(BllResult);
                Assert.IsTrue(BllResult.Result, "Result is false.");
                AreaComparer.Instance.Compare(Expected, area);
            }
        }