コード例 #1
0
        public CTCGUITest()
        {
            //using all testing classes the ctc office (created a new instance of ctc)

            //create environment instance
            _env = new SimulationEnvironment.SimulationEnvironment();

            //create testing track model
            _trackMod = new TestingTrackModel(_env);

            //creating testing track controllers
            _red   = new TestingTrackController(0, _trackMod, _env, true);
            _green = new TestingTrackController(1, _trackMod, _env, true);

            //hook to environment
            _env.PrimaryTrackControllerRed   = _red;
            _env.PrimaryTrackControllerGreen = _green;
            _env.TrackModel = _trackMod;

            //creating office instance
            _ctc = new CTCOffice.CTCOffice(_env, _red, _green);

            _env.CTCOffice        = _ctc;
            _ctc.StartAutomation += new EventHandler <EventArgs>(_ctc_StartAutomation);
            _ctc.StopAutomation  += new EventHandler <EventArgs>(_ctc_StopAutomation);

            //making Request Panel Objects (For red and green)
            _redRequest   = new RequestFrame("Red", _red);
            _greenRequest = new RequestFrame("Green", _green);

            //creating office gui
            _ctcGui = new CTCOfficeGUI(_env, _ctc);
            _ctcGui.ShowSchedule += new EventHandler <EventArgs>(_ctcGui_ShowSchedule);


            var MyTestingControls = new TestingControls(_trackMod);

            //creating testing gui
            _control = new OfficeGUITest(
                _ctcGui,
                _redRequest,
                _greenRequest,
                MyTestingControls
                );

            _env.StartTick();

            Form f = new Form();

            f.AutoSize = true;
            f.Text     = "CTC Office Standalone GUI Test";
            f.Controls.Add(_control);
            f.Show();
        }
コード例 #2
0
        public CTCGUITest()
        {
            //using all testing classes the ctc office (created a new instance of ctc)

            //create environment instance
            _env = new SimulationEnvironment.SimulationEnvironment();

            //create testing track model
            _trackMod = new TestingTrackModel(_env);

            //creating testing track controllers
            _red = new TestingTrackController(0,_trackMod,_env, true);
            _green = new TestingTrackController(1,_trackMod,_env, true);

            //hook to environment
            _env.PrimaryTrackControllerRed = _red;
            _env.PrimaryTrackControllerGreen = _green;
            _env.TrackModel = _trackMod;

            //creating office instance
            _ctc = new CTCOffice.CTCOffice(_env, _red, _green);

            _env.CTCOffice = _ctc;
            _ctc.StartAutomation += new EventHandler<EventArgs>(_ctc_StartAutomation);
            _ctc.StopAutomation += new EventHandler<EventArgs>(_ctc_StopAutomation);

            //making Request Panel Objects (For red and green)
            _redRequest = new RequestFrame("Red", _red);
            _greenRequest = new RequestFrame("Green", _green);

            //creating office gui
            _ctcGui = new CTCOfficeGUI(_env, _ctc);
            _ctcGui.ShowSchedule += new EventHandler<EventArgs>(_ctcGui_ShowSchedule);

            var MyTestingControls = new TestingControls(_trackMod);
            //creating testing gui
            _control = new OfficeGUITest(
                _ctcGui,
                _redRequest,
                _greenRequest,
                MyTestingControls
                );

            _env.StartTick();

            Form f = new Form();
            f.AutoSize = true;
            f.Text = "CTC Office Standalone GUI Test";
            f.Controls.Add(_control);
            f.Show();
        }
コード例 #3
0
        private static Form GuiTestFramework(int test)
        {
            ////////////////////////////////////////////////////////////////////////////////////////
            //                              Initializations                                       //
            ////////////////////////////////////////////////////////////////////////////////////////

            // Environment object
            var environment = new SimulationEnvironment.SimulationEnvironment();

            IBlock b0 = new TrackModel.Block(1, StateEnum.Healthy, 0, 0, 0, new[] {0, 0}, 10, DirEnum.East, new[] {""}, 0, 0, 0, "Red",70);
            IBlock b1 = new TrackModel.Block(2, StateEnum.Healthy, 1, 0, 0, new[] {1, 1}, 10, DirEnum.East, new[] {""}, 0, 0, 0, "Red",70);
            IBlock b2 = new TrackModel.Block(3, StateEnum.Healthy, 2, 0, 0, new[] {2, 2}, 10, DirEnum.East, new[] {""}, 0, 0, 0, "Red",70);
            IBlock b3 = new TrackModel.Block(4, StateEnum.BrokenTrackFailure, 3, 0, 0, new[] {3, 3}, 10, DirEnum.East, new[] {""}, 0, 0, 0, "Red",70);

            var sectionA = new List<IBlock> {b0};
            var sectionB = new List<IBlock> {b1, b2};
            var sectionC = new List<IBlock> {b3};

            // Previous track controller's circuit
            var prevCircuit = new TrackCircuit(environment, sectionA);
            // Our track circuit
            var currCircuit = new TrackCircuit(environment, sectionB);
            // Next track controller's circuit
            var nextCircuit = new TrackCircuit(environment, sectionC);

            var prev = new TrackController.TrackController(environment, prevCircuit);
            var curr = new TrackController.TrackController(environment, currCircuit);
            var next = new TrackController.TrackController(environment, nextCircuit);

            //Create TrackModel
            var trackMod = new TrackModel.TrackModel(environment);
            //Let TrackModel read in the lines before you proceed..shouldnt be done this way, but needed to stop CTC Office from faulting
            bool res = trackMod.provideInputFile("red.csv");
            //Console.WriteLine("Res was "+res);
            res = trackMod.provideInputFile("green.csv");
            //Console.WriteLine("Res was " + res);

            environment.TrackModel = trackMod;
            prev.Previous = null;
            prev.Next = curr;

            curr.Previous = prev;
            curr.Next = next;

            next.Previous = curr;
            next.Next = null;

            // Assign the same track controller to both lines
            var office = new CTCOffice.CTCOffice(environment, prev, prev);

            environment.CTCOffice = office;
            environment.PrimaryTrackControllerGreen = prev;
            environment.PrimaryTrackControllerRed = prev;

            ////////////////////////////////////////////////////////////////////////////////////////
            //                            End Initializations                                     //
            ////////////////////////////////////////////////////////////////////////////////////////

            var form = new Form();
            var control = new UserControl();
            switch (test)
            {
                case 0: // SystemScheduler

                    var testSystemScheduler = new SystemScheduler.SystemScheduler(environment, office);
                    control = new SystemSchedulerGUI(environment, testSystemScheduler, office);
                    environment.StartTick();
                    break;
                case 1: // CTCOffice
                    environment = null;

                    b0 = null;
                    b1 = null;
                    b2 = null;
                    b3 = null;

                    sectionA = null;
                    sectionB = null;
                    sectionC = null;

                    prevCircuit = null;
                    currCircuit = null;
                    nextCircuit = null;

                    prev = null;
                    curr = null;
                    next = null;

                    trackMod = null;
                    office = null;

                    new CTCGUITest();
                    break;
                case 2: // TrackModel
                    control = new TrackModelGUI(environment, trackMod);
                    break;
                case 3: // TrackController
                    ITrainModel t = new Train(0, b0, environment);

                    environment.AllTrains.Add(t);

                    prevCircuit.Trains.Add(0, t);

                    control = new TrackControllerUi(environment, environment.PrimaryTrackControllerRed);
                    break;
                case 4: // TrainModel
                    var loc = new int[2];
                    loc[0] = 10;
                    loc[1] = 10;
                    var start = new Block(0, StateEnum.Healthy, 0, 0, -0.02, loc, 100, DirEnum.East, null, 1, 2, 0, "Red",70);
                    environment.AddTrain(new Train(0, start, environment));
                    environment.AddTrain(new Train(1, start, environment));

                    var train0 = (Train)environment.AllTrains[0];
                    train0.ChangeMovement(200);

                    control = new TrainGUI(environment);

                    break;
                case 5: // TrainController
                    var loc2 = new int[2];
                    loc2[0] = 10;
                    loc2[1] = 10;
                    var start2 = new Block(0, StateEnum.Healthy, 0, 0, 0, loc2, 100, DirEnum.East, null, 1, 2, 0, "Red",70);
                    var tc = new TrainController.TrainController(environment, new Train(0, start2, environment));
                    control = new TrainControllerUI(tc, environment);
                    break;
            }

            if (environment != null)
            {
                environment.StartTick();
            }

            if (form != null)
            {
                form.Controls.Add(control);
                form.AutoSize = true;
            }
            else
            {
                return null;
            }

            return form;
        }
コード例 #4
0
        public bool DoTest(out int pass, out int fail, out List<string> message)
        {
            pass = 0;
            fail = 0;
            message = new List<string>();

            ISimulationEnvironment environment = new SimulationEnvironment.SimulationEnvironment();
            SystemScheduler.CTC_Dummy fakeCTC = new SystemScheduler.CTC_Dummy(environment);
            CTCOffice.TestingTrackModel tm = new CTCOffice.TestingTrackModel(environment);
            environment.TrackModel = tm;
            var testSystemScheduler = new SystemScheduler.SystemScheduler(environment, fakeCTC);
            environment.StartTick();

            /////////////////////////////////
            //Test 1
            //Check that there is no initial dispatch database loaded
            if (testSystemScheduler.DispatchDatabase == null)
            {
                pass++;
                message.Add("Pass: The DispatchDatabase is initially null");
            }
            else
            {
                fail++;
                message.Add("Fail: The DispatchDatabase is not initially null. Did you hardcode it to load, you n00b?");
            }
            //End test 1
            /////////////////////////////////

            /////////////////////////////////
            //Test 2
            //Attempt to load a database that doesn't exist
            testSystemScheduler.NewFile("theresnowaythisactuallyexistslol");
            if (testSystemScheduler.DispatchDatabase == null)
            {
                pass++;
                message.Add("Pass: The scheduler responded correctly to an attempt to load a missing file.");
            }
            else
            {
                fail++;
                message.Add("Fail: I'm not sure how you would get here, but just in case, your scheduler is loading from files that don't exist. Nice.");
            }
            //End test 2
            /////////////////////////////////

            /////////////////////////////////
            //Test 3
            //Attempt to load a database that isn't properly formatted
            testSystemScheduler.NewFile("..\\..\\Resources\\Computer Benchmarks.csv");
            if (testSystemScheduler.DispatchDatabase == null)
            {
                pass++;
                message.Add("Pass: The scheduler responded correctly to an attempt to load an improperly formatted file.");
            }
            else
            {
                fail++;
                message.Add("Fail: If you see me, it means your error checking isn't robust enough :) It loaded a bad file.");
            }
            //End test 3
            /////////////////////////////////

            /////////////////////////////////
            //Test 4
            //Attempt to enable the scheduler without a database loaded - it should fail
            fakeCTC.StartScheduling();
            if (testSystemScheduler.IsEnabled == false)
            {
                pass++;
                message.Add("Pass: The scheduler responded correctly to an attempt to enable automated scheduling before loading a database.");
            }
            else
            {
                fail++;
                message.Add("Fail: The scheduler allowed itself to be enabled before the database was loaded. This is like 2 steps away from SkyNet. Fix it!");
            }
            //End test 4
            /////////////////////////////////

            /////////////////////////////////
            //Test 5
            //Attempt to load a correctly formatted database
            testSystemScheduler.NewFile("..\\..\\Resources\\Correct File.csv");
            if (testSystemScheduler.DispatchDatabase.SuccessfulParse == true)
            {
                pass++;
                message.Add("Pass: The scheduler loaded in the values from a database.");
            }
            else
            {
                fail++;
                message.Add("Fail: Your scheduler did not load in the data it was supposed to. Find out what went wrong!");
            }
            //End test 5
            /////////////////////////////////

            /////////////////////////////////
            //Test 6
            //Did it load the correct number of dispatches
            if (testSystemScheduler.DispatchDatabase.DispatchList.Count == 5)
            {
                pass++;
                message.Add("Pass: The scheduler loaded in the correct number of values from a database.");
            }
            else
            {
                fail++;
                message.Add("Fail: Your scheduler did not load in the correct amount of data it was supposed to. Check the file to see if it's messed up.");
            }
            //End test 6
            /////////////////////////////////

            /////////////////////////////////
            //Test 7
            //Can it delete from the database
            testSystemScheduler.DispatchDatabase.RemoveDispatch(1);
            if (testSystemScheduler.DispatchDatabase.DispatchList.Count == 4)
            {
                pass++;
                message.Add("Pass: The scheduler was able to remove a dispatch from its database.");
            }
            else
            {
                fail++;
                message.Add("Fail: Your scheduler did not remove a record from the database. Check to make sure the file is okay.");
            }
            //End test 7
            /////////////////////////////////

            /////////////////////////////////
            //Test 8
            //Can it add to the database
            testSystemScheduler.DispatchDatabase.AddDispatch("-1", "3:00 AM", "1", "Red", "0");
            testSystemScheduler.DispatchDatabase.AddDispatch("-1", "3:00 AM", "1", "Red", "0");
            if (testSystemScheduler.DispatchDatabase.DispatchList.Count == 6)
            {
                pass++;
                message.Add("Pass: The scheduler was able to add 2 dispatch orders to its database.");
            }
            else
            {
                fail++;
                message.Add("Fail: Your scheduler did not add records to the database. Find out what went wrong.");
            }
            //End test 8
            /////////////////////////////////

            /////////////////////////////////
            //Test 9
            //Can it add to the database without generating a new ID
            testSystemScheduler.DispatchDatabase.AddDispatch("7", "3:00 AM", "1", "Green", "1");
            if (testSystemScheduler.DispatchDatabase.DispatchList.Count == 7)
            {
                pass++;
                message.Add("Pass: The scheduler was able to add a dispatch order without generating and ID to its database.");
            }
            else
            {
                fail++;
                message.Add("Fail: Your scheduler did not add records to the database as would occur in an edit. If test 7 works, you can probably guess where this is broken.");
            }
            //End test 9
            /////////////////////////////////

            /////////////////////////////////
            //Test 10
            //Attempt to enable the scheduler with a database loaded - it should be ok
            fakeCTC.StartScheduling();
            if (testSystemScheduler.IsEnabled == true)
            {
                pass++;
                message.Add("Pass: The scheduler responded correctly to an attempt to enable automated scheduling.");
            }
            else
            {
                fail++;
                message.Add("Fail: The scheduler was not enabled after a call was made for it to do just that. For shame.");
            }
            //End test 10
            /////////////////////////////////

            /////////////////////////////////
            //Test 11
            //Attempt to disable the scheduler with a database loaded - it should be ok
            fakeCTC.StopScheduling();
            if (testSystemScheduler.IsEnabled == false)
            {
                pass++;
                message.Add("Pass: The scheduler responded correctly to an attempt to disable automated scheduling.");
            }
            else
            {
                fail++;
                message.Add("Fail: The scheduler was not disabled after a call was made for it to do just that. For shame. Again.");
            }
            //End test 11
            /////////////////////////////////

            /////////////////////////////////
            //Test 12
            //Check to see if time is running for the scheduler
            DateTime temporaryTime = testSystemScheduler.SchedulerTime;
            System.Threading.Thread.Sleep(5000);
            if (!testSystemScheduler.SchedulerTime.Equals(temporaryTime))
            {
                pass++;
                message.Add("Pass: The scheduler is incrementing the time correctly. Thank god for that.");
            }
            else
            {
                fail++;
                message.Add("Fail: The scheduler is not incrementing time correctly. You are so screwed.");
            }
            //End test 12
            /////////////////////////////////

            return true;
        }
コード例 #5
0
        public bool DoTest(out int pass, out int fail, out List <string> message)
        {
            pass    = 0;
            fail    = 0;
            message = new List <string>();


            ISimulationEnvironment environment = new SimulationEnvironment.SimulationEnvironment();

            SystemScheduler.CTC_Dummy   fakeCTC = new SystemScheduler.CTC_Dummy(environment);
            CTCOffice.TestingTrackModel tm      = new CTCOffice.TestingTrackModel(environment);
            environment.TrackModel = tm;
            var testSystemScheduler = new SystemScheduler.SystemScheduler(environment, fakeCTC);

            environment.StartTick();


            /////////////////////////////////
            //Test 1
            //Check that there is no initial dispatch database loaded
            if (testSystemScheduler.DispatchDatabase == null)
            {
                pass++;
                message.Add("Pass: The DispatchDatabase is initially null");
            }
            else
            {
                fail++;
                message.Add("Fail: The DispatchDatabase is not initially null. Did you hardcode it to load, you n00b?");
            }
            //End test 1
            /////////////////////////////////

            /////////////////////////////////
            //Test 2
            //Attempt to load a database that doesn't exist
            testSystemScheduler.NewFile("theresnowaythisactuallyexistslol");
            if (testSystemScheduler.DispatchDatabase == null)
            {
                pass++;
                message.Add("Pass: The scheduler responded correctly to an attempt to load a missing file.");
            }
            else
            {
                fail++;
                message.Add("Fail: I'm not sure how you would get here, but just in case, your scheduler is loading from files that don't exist. Nice.");
            }
            //End test 2
            /////////////////////////////////

            /////////////////////////////////
            //Test 3
            //Attempt to load a database that isn't properly formatted
            testSystemScheduler.NewFile("..\\..\\Resources\\Computer Benchmarks.csv");
            if (testSystemScheduler.DispatchDatabase == null)
            {
                pass++;
                message.Add("Pass: The scheduler responded correctly to an attempt to load an improperly formatted file.");
            }
            else
            {
                fail++;
                message.Add("Fail: If you see me, it means your error checking isn't robust enough :) It loaded a bad file.");
            }
            //End test 3
            /////////////////////////////////

            /////////////////////////////////
            //Test 4
            //Attempt to enable the scheduler without a database loaded - it should fail
            fakeCTC.StartScheduling();
            if (testSystemScheduler.IsEnabled == false)
            {
                pass++;
                message.Add("Pass: The scheduler responded correctly to an attempt to enable automated scheduling before loading a database.");
            }
            else
            {
                fail++;
                message.Add("Fail: The scheduler allowed itself to be enabled before the database was loaded. This is like 2 steps away from SkyNet. Fix it!");
            }
            //End test 4
            /////////////////////////////////

            /////////////////////////////////
            //Test 5
            //Attempt to load a correctly formatted database
            testSystemScheduler.NewFile("..\\..\\Resources\\Correct File.csv");
            if (testSystemScheduler.DispatchDatabase.SuccessfulParse == true)
            {
                pass++;
                message.Add("Pass: The scheduler loaded in the values from a database.");
            }
            else
            {
                fail++;
                message.Add("Fail: Your scheduler did not load in the data it was supposed to. Find out what went wrong!");
            }
            //End test 5
            /////////////////////////////////

            /////////////////////////////////
            //Test 6
            //Did it load the correct number of dispatches
            if (testSystemScheduler.DispatchDatabase.DispatchList.Count == 5)
            {
                pass++;
                message.Add("Pass: The scheduler loaded in the correct number of values from a database.");
            }
            else
            {
                fail++;
                message.Add("Fail: Your scheduler did not load in the correct amount of data it was supposed to. Check the file to see if it's messed up.");
            }
            //End test 6
            /////////////////////////////////

            /////////////////////////////////
            //Test 7
            //Can it delete from the database
            testSystemScheduler.DispatchDatabase.RemoveDispatch(1);
            if (testSystemScheduler.DispatchDatabase.DispatchList.Count == 4)
            {
                pass++;
                message.Add("Pass: The scheduler was able to remove a dispatch from its database.");
            }
            else
            {
                fail++;
                message.Add("Fail: Your scheduler did not remove a record from the database. Check to make sure the file is okay.");
            }
            //End test 7
            /////////////////////////////////

            /////////////////////////////////
            //Test 8
            //Can it add to the database
            testSystemScheduler.DispatchDatabase.AddDispatch("-1", "3:00 AM", "1", "Red", "0");
            testSystemScheduler.DispatchDatabase.AddDispatch("-1", "3:00 AM", "1", "Red", "0");
            if (testSystemScheduler.DispatchDatabase.DispatchList.Count == 6)
            {
                pass++;
                message.Add("Pass: The scheduler was able to add 2 dispatch orders to its database.");
            }
            else
            {
                fail++;
                message.Add("Fail: Your scheduler did not add records to the database. Find out what went wrong.");
            }
            //End test 8
            /////////////////////////////////

            /////////////////////////////////
            //Test 9
            //Can it add to the database without generating a new ID
            testSystemScheduler.DispatchDatabase.AddDispatch("7", "3:00 AM", "1", "Green", "1");
            if (testSystemScheduler.DispatchDatabase.DispatchList.Count == 7)
            {
                pass++;
                message.Add("Pass: The scheduler was able to add a dispatch order without generating and ID to its database.");
            }
            else
            {
                fail++;
                message.Add("Fail: Your scheduler did not add records to the database as would occur in an edit. If test 7 works, you can probably guess where this is broken.");
            }
            //End test 9
            /////////////////////////////////

            /////////////////////////////////
            //Test 10
            //Attempt to enable the scheduler with a database loaded - it should be ok
            fakeCTC.StartScheduling();
            if (testSystemScheduler.IsEnabled == true)
            {
                pass++;
                message.Add("Pass: The scheduler responded correctly to an attempt to enable automated scheduling.");
            }
            else
            {
                fail++;
                message.Add("Fail: The scheduler was not enabled after a call was made for it to do just that. For shame.");
            }
            //End test 10
            /////////////////////////////////

            /////////////////////////////////
            //Test 11
            //Attempt to disable the scheduler with a database loaded - it should be ok
            fakeCTC.StopScheduling();
            if (testSystemScheduler.IsEnabled == false)
            {
                pass++;
                message.Add("Pass: The scheduler responded correctly to an attempt to disable automated scheduling.");
            }
            else
            {
                fail++;
                message.Add("Fail: The scheduler was not disabled after a call was made for it to do just that. For shame. Again.");
            }
            //End test 11
            /////////////////////////////////

            /////////////////////////////////
            //Test 12
            //Check to see if time is running for the scheduler
            DateTime temporaryTime = testSystemScheduler.SchedulerTime;

            System.Threading.Thread.Sleep(5000);
            if (!testSystemScheduler.SchedulerTime.Equals(temporaryTime))
            {
                pass++;
                message.Add("Pass: The scheduler is incrementing the time correctly. Thank god for that.");
            }
            else
            {
                fail++;
                message.Add("Fail: The scheduler is not incrementing time correctly. You are so screwed.");
            }
            //End test 12
            /////////////////////////////////


            return(true);
        }
コード例 #6
0
        private static Form GuiTestFramework(int test)
        {
            ////////////////////////////////////////////////////////////////////////////////////////
            //                              Initializations                                       //
            ////////////////////////////////////////////////////////////////////////////////////////


            // Environment object
            var environment = new SimulationEnvironment.SimulationEnvironment();

            IBlock b0 = new TrackModel.Block(1, StateEnum.Healthy, 0, 0, 0, new[] { 0, 0 }, 10, DirEnum.East, new[] { "" }, 0, 0, 0, "Red", 70);
            IBlock b1 = new TrackModel.Block(2, StateEnum.Healthy, 1, 0, 0, new[] { 1, 1 }, 10, DirEnum.East, new[] { "" }, 0, 0, 0, "Red", 70);
            IBlock b2 = new TrackModel.Block(3, StateEnum.Healthy, 2, 0, 0, new[] { 2, 2 }, 10, DirEnum.East, new[] { "" }, 0, 0, 0, "Red", 70);
            IBlock b3 = new TrackModel.Block(4, StateEnum.BrokenTrackFailure, 3, 0, 0, new[] { 3, 3 }, 10, DirEnum.East, new[] { "" }, 0, 0, 0, "Red", 70);

            var sectionA = new List <IBlock> {
                b0
            };
            var sectionB = new List <IBlock> {
                b1, b2
            };
            var sectionC = new List <IBlock> {
                b3
            };

            // Previous track controller's circuit
            var prevCircuit = new TrackCircuit(environment, sectionA);
            // Our track circuit
            var currCircuit = new TrackCircuit(environment, sectionB);
            // Next track controller's circuit
            var nextCircuit = new TrackCircuit(environment, sectionC);

            var prev = new TrackController.TrackController(environment, prevCircuit);
            var curr = new TrackController.TrackController(environment, currCircuit);
            var next = new TrackController.TrackController(environment, nextCircuit);

            //Create TrackModel
            var trackMod = new TrackModel.TrackModel(environment);
            //Let TrackModel read in the lines before you proceed..shouldnt be done this way, but needed to stop CTC Office from faulting
            bool res = trackMod.provideInputFile("red.csv");

            //Console.WriteLine("Res was "+res);
            res = trackMod.provideInputFile("green.csv");
            //Console.WriteLine("Res was " + res);


            environment.TrackModel = trackMod;
            prev.Previous          = null;
            prev.Next = curr;

            curr.Previous = prev;
            curr.Next     = next;

            next.Previous = curr;
            next.Next     = null;

            // Assign the same track controller to both lines
            var office = new CTCOffice.CTCOffice(environment, prev, prev);

            environment.CTCOffice = office;
            environment.PrimaryTrackControllerGreen = prev;
            environment.PrimaryTrackControllerRed   = prev;


            ////////////////////////////////////////////////////////////////////////////////////////
            //                            End Initializations                                     //
            ////////////////////////////////////////////////////////////////////////////////////////

            var form    = new Form();
            var control = new UserControl();

            switch (test)
            {
            case 0:     // SystemScheduler

                var testSystemScheduler = new SystemScheduler.SystemScheduler(environment, office);
                control = new SystemSchedulerGUI(environment, testSystemScheduler, office);
                environment.StartTick();
                break;

            case 1:     // CTCOffice
                environment = null;

                b0 = null;
                b1 = null;
                b2 = null;
                b3 = null;

                sectionA = null;
                sectionB = null;
                sectionC = null;

                prevCircuit = null;
                currCircuit = null;
                nextCircuit = null;

                prev = null;
                curr = null;
                next = null;

                trackMod = null;
                office   = null;

                new CTCGUITest();
                break;

            case 2:     // TrackModel
                control = new TrackModelGUI(environment, trackMod);
                break;

            case 3:     // TrackController
                ITrainModel t = new Train(0, b0, environment);

                environment.AllTrains.Add(t);

                prevCircuit.Trains.Add(0, t);

                control = new TrackControllerUi(environment, environment.PrimaryTrackControllerRed);
                break;

            case 4:     // TrainModel
                var loc = new int[2];
                loc[0] = 10;
                loc[1] = 10;
                var start = new Block(0, StateEnum.Healthy, 0, 0, -0.02, loc, 100, DirEnum.East, null, 1, 2, 0, "Red", 70);
                environment.AddTrain(new Train(0, start, environment));
                environment.AddTrain(new Train(1, start, environment));

                var train0 = (Train)environment.AllTrains[0];
                train0.ChangeMovement(200);

                control = new TrainGUI(environment);

                break;

            case 5:     // TrainController
                var loc2 = new int[2];
                loc2[0] = 10;
                loc2[1] = 10;
                var start2 = new Block(0, StateEnum.Healthy, 0, 0, 0, loc2, 100, DirEnum.East, null, 1, 2, 0, "Red", 70);
                var tc     = new TrainController.TrainController(environment, new Train(0, start2, environment));
                control = new TrainControllerUI(tc, environment);
                break;
            }

            if (environment != null)
            {
                environment.StartTick();
            }

            if (form != null)
            {
                form.Controls.Add(control);
                form.AutoSize = true;
            }
            else
            {
                return(null);
            }


            return(form);
        }