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(); }
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(); }
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(); var tm = new TrackModel.TrackModel(environment); ///////////////////////////////// //Test 1 //Check that RedLoaded is initially false if (tm.RedLoaded == false) { pass++; message.Add("Pass: RedLoaded is initially false"); } else { fail++; message.Add("Fail: RedLoaded was not initially false, as it should be prior to loading RedLine"); } //End test 1 ///////////////////////////////// ///////////////////////////////// //Test 2 //Check that GreenLoaded is initially false if (tm.GreenLoaded == false) { pass++; message.Add("Pass: GreenLoaded is initially false, as desired"); } else { fail++; message.Add("Fail: GreenLoaded was not initially false, as it should be prior to loading GreenLine"); } ///////////////////////////////// ///////////////////////////////// //Test 3 //provideInputFile returns false when given bad input file bool resBool = tm.provideInputFile("asdfawecxwe");/** Gee, Really hope this file doesnt exist*/ if (resBool == false) { pass++; message.Add("Pass: provideInputFile returns false when given bad file"); } else { fail++; message.Add("Fail: provideInputFile didn't return false when given an invalid filename"); } //End Test 3 ///////////////////////////////// ///////////////////////////////// //Test 4 //provideInputFile should return false when given a null argument resBool = tm.provideInputFile(null); if (resBool == false) { pass++; message.Add("Pass: provideInputFile returns false when given a null argument"); } else { fail++; message.Add("Fail: provideInputFile should return false when given a null argument"); } //End Test 4 ///////////////////////////////// ///////////////////////////////// //Test 5 //provideInputFile should return false when given a non-csv file resBool = tm.provideInputFile(@"..\..\red.bad");//An existent but non csv file if (resBool == false) { pass++; message.Add("Pass: provideInputFile returns false when given a non-csv file"); } else { fail++; message.Add("Fail: provideInputFile did not return false when given a non-csv file as expected"); } //End Test 5 ///////////////////////////////// ///////////////////////////////// //Test 6 //provideInputFile should return true when given a valid file resBool = tm.provideInputFile(@"..\..\red.csv"); if (resBool == true) { pass++; message.Add("Pass: provideInputFile returned true when given a valid, existing, and properly formatted file (red.csv)"); } else { fail++; message.Add("Pass: provideInputFile returned false when given a valid and proper file, expected val was true (red.csv)"); } //End Test 6 ///////////////////////////////// ///////////////////////////////// //Test 7 //provideInputFile should return true when given a valid file resBool = tm.provideInputFile(@"..\..\green.csv"); if (resBool == true) { pass++; message.Add("Pass: provideInputFile returned true when given a valid, existing, and properly formatted file (green.csv)"); } else { fail++; message.Add("Pass: provideInputFile returned false when given a valid and proper file, expected val was true (green.csv)"); } //End Test 7 ///////////////////////////////// ///////////////////////////////// //Test 8 //Check that RedLoaded property returns true after loading if (tm.RedLoaded) { pass++; message.Add("Pass: the RedLoaded Property shows that the red line has now been loaded"); } else { fail++; message.Add("Fail: the RedLoaded Property does not show that the red line has been loaded"); } //End Test 8 ///////////////////////////////// ///////////////////////////////// //Test 9 if (tm.GreenLoaded) { pass++; message.Add("Pass: The GreenLoaded Property shows that the green line has now been loaded"); } else { fail++; message.Add("Fail: The GreenLoaded Property does not show that the green line has been loaded"); } //End Test 9 ///////////////////////////////// ///////////////////////////////// //Test 10 //requestBlockInfo should return null when given a negative block number IBlock tempIBlock = tm.requestBlockInfo(-1, "Red"); if (tempIBlock == null) { pass++; message.Add("Pass: requestBlockInfo returned null when given a negative blockID"); } else { fail++; message.Add("Fail: requestBlockInfo returned a valid block when given negative blockID, expected val was null"); } //End Test 10 ///////////////////////////////// ///////////////////////////////// //Test 11 //requestBlockInfo should return null when given a blockID=0 tempIBlock = tm.requestBlockInfo(0, "Red"); if (tempIBlock != null) { pass++; message.Add("Pass: requestBlockInfo was able to retrieve the 0 block of a line"); } else { fail++; message.Add("Fail: requestBlockInfo returned null when given blockID=0, expected val was valid block"); } //End Test 11 ///////////////////////////////// ///////////////////////////////// //Test 12 //requestBlockInfo should return null when asked to retrieve an out-of-range block id tempIBlock = tm.requestBlockInfo(19191, "Red"); if (tempIBlock == null) { pass++; message.Add("Pass: requestBlockInfo returned null as expected when given an out of range block ID"); } else { fail++; message.Add("Fail: requestBlockInfo did not return null when given an out of range blockID, expected val was null"); } //End Test 12 ///////////////////////////////// ///////////////////////////////// //Test 13 //requestBlockInfo should return null when given a bad line string tempIBlock = tm.requestBlockInfo(0, "asdf"); if (tempIBlock == null) { pass++; message.Add("Pass: requestBlockInfo returned null when given an invalid line string"); } else { fail++; message.Add("Fail: requestBlockInfo did not return null when given an invalid line string"); } //End Test 13 ///////////////////////////////// ///////////////////////////////// //Test 14 //requestBlockInfo should return a valid block when asked to retrieve a basic block (without extra infrastructure) tempIBlock = tm.requestBlockInfo(1, "Red"); if (tempIBlock != null) { pass++; message.Add("Pass: requestBlockInfo successfully returned a basic block without extra infrastructure"); } else { fail++; message.Add("Fail: requestBlockInfo returned null when asked to retrieve a basic block without extra infrastructure"); } //End Test 14 ///////////////////////////////// ///////////////////////////////// //Test 15 //requestBlockInfo should return a valid block when asked to retrieve a more complex block (containing infrastructure such as switch, heater, etc). tempIBlock = tm.requestBlockInfo(27, "Red"); if (tempIBlock != null) { pass++; message.Add("Pass: requestBlockInfo successfully returned a complex block (with additional infra)"); } else { fail++; message.Add("Fail: requestBlockInfo returns null when asked for a more complex block (with additional infra)"); } //End Test 15 ///////////////////////////////// ///////////////////////////////// //Test 16 //requestUpdateBlock returns false when provided with a null value resBool = tm.requestUpdateBlock(null); if (resBool == false) { pass++; message.Add("Pass: requestUpdateBlock returns false when given a null value"); } else { fail++; message.Add("Fail: requestUpdateBlock returns true when given a null value, expected value is false"); } //End Test 16 ///////////////////////////////// ///////////////////////////////// //Test 17 //requestUpdateBlock returns false when provided with a block w/ ID=0 (no updating the yard) tempIBlock = tm.requestBlockInfo(0, "Red"); resBool = tm.requestUpdateBlock(tempIBlock); if (resBool == false) { pass++; message.Add("Pass: requestUpdateBlock returned false when attempting to update 0 block (yard)"); } else { fail++; message.Add("Fail: requestUpdateBlock returned true when attempting to update 0 block (yard), expected value was false"); } //End Test 17 ///////////////////////////////// ///////////////////////////////// //Test 18 //requestBlockUpdate should allow change of Health State tempIBlock = tm.requestBlockInfo(1, "Red"); //Store old state, and assign new state in a way that ensures oldState and newState are different var oldState = tempIBlock.State; if (oldState != StateEnum.CircuitFailure) { tempIBlock.State = StateEnum.CircuitFailure; } else { tempIBlock.State = StateEnum.BrokenTrackFailure; } //Update the block resBool = tm.requestUpdateBlock(tempIBlock); //Re-request info from database tempIBlock = tm.requestBlockInfo(1, "Red"); if (resBool && tempIBlock.State != oldState) { pass++; } else if (!resBool && tempIBlock.State == oldState) { fail++; message.Add("Fail: requestUpdateBlock returnd a false value, when given a changed state, expected val was true"); } else { fail++; message.Add("Fail: requestUpdateBlock returned true, but failed to update the database"); } //End Test 18 ///////////////////////////////// ///////////////////////////////// //Test 19 //requestUpdateBlock should allow updating of heater state ////////////////////////////////// //THIS NEEDS IMPLEMENTED STILL //No blocks in the init file contain heaters by default //Should I assume that every block has a heater? //I prob want to write a method in the BLOCK object that lets you turn the heater on and off // ////////////////////////////////// //End Test 19 ///////////////////////////////// ///////////////////////////////// //Test 20 //requestUpdateBlock should return true but fail to update swith when asked to update switch information in db tempIBlock = tm.requestBlockInfo(1, "Red"); int oldSD1 = tempIBlock.SwitchDest1; tempIBlock.SwitchDest1 = tempIBlock.SwitchDest2; tempIBlock.SwitchDest2 = oldSD1; resBool = tm.requestUpdateBlock(tempIBlock); tempIBlock = tm.requestBlockInfo(1, "Red"); if (resBool == true && tempIBlock.SwitchDest1 == oldSD1) { pass++; message.Add("Pass: requestUpdateBlock did not update Switch state in database"); } else { fail++; message.Add("Fail: either the returned boolean was false, or the data was updated in the db."); } //End Test 20 ///////////////////////////////// ///////////////////////////////// //Test 21 //requestRouteInfo should return a null value when given a negative route ID IRouteInfo tempIRouteInfo = tm.requestRouteInfo(-1); if (tempIRouteInfo == null) { pass++; message.Add("Pass: requestRouteInfo returns null when given a negative routeID"); } else { fail++; message.Add("Fail: requestRouteInfo returned a Route when given a negative routeID, expected val was null"); } //End Test 21 ///////////////////////////////// ///////////////////////////////// //Test 22 //requestRouteInfo should return a null value when given a line other than 0 or 1 tempIRouteInfo = tm.requestRouteInfo(2); if (tempIRouteInfo == null) { pass++; message.Add("Pass: requestRouteInfo returns null when given an out of range routeID"); } else { fail++; message.Add("Fail: requestRouteInfo returned a Route when given an out of range route ID, expected val was null"); } //End Test 22 ///////////////////////////////// ///////////////////////////////// //Test 23 //requestRouteInfo returns a valid IRouteInfo object when given a line ID of 0 or 1 tempIRouteInfo = tm.requestRouteInfo(0); if (tempIRouteInfo != null) { pass++; message.Add("Pass: requestRouteInfo returns valid IRouteInfo when given valid lineID"); } else { fail++; message.Add("Fail: requestRouteInfo returns null when given valid lineID, expected val was null"); } //End Test 23 ///////////////////////////////// ///////////////////////////////// //Test 24 //requestTrackGrid should return null when given an invalid line ID IBlock[,] tempIBlockArr = tm.requestTrackGrid(-1); if (tempIBlockArr == null) { pass++; message.Add("Pass: requestTrackGrid returns null when given invalid line ID"); } else { fail++; message.Add("Fail: requestTrackGrid returns valid IBlock[,] when given invalid line id, expected value was null"); } //End Test 24 ///////////////////////////////// ///////////////////////////////// //Test 25 //requestTrackGrid should return valid IBlock[,] when given valid line ID tempIBlockArr = tm.requestTrackGrid(0); if (tempIBlockArr != null) { pass++; message.Add("Pass: requestTrackGrid returns valid IBlock[,] when given valid line id"); } else { fail++; message.Add("Fail: requestTrackGrid returns null when given valid line id, expected val was IBlock[,] object"); } //End Test 25 ///////////////////////////////// ///////////////////////////////// //Test 26 //requestUpdateSwitch should return false when given a null Block value resBool = tm.requestUpdateSwitch(null); if (resBool == false) { pass++; message.Add("Pass: requestUpdateSwitch returns false when given a null parameter"); } else { fail++; message.Add("Fail: requestUpdateSwitch returns true when given a null parameter, expected value was false"); } //End Test 26 ///////////////////////////////// ///////////////////////////////// //Test 27 //requestUpdateSwitch should return false when given a block that doesnt contain a switch tempIBlock = tm.requestBlockInfo(1, "Red"); resBool = tm.requestUpdateSwitch(tempIBlock); if (resBool == false) { pass++; message.Add("Pass: requestUpdateSwitch returns false when given a block without a switch"); } else { fail++; message.Add("Fail: requestUpdateSwitch returns true when given a block without a switch"); } //End Test 27 ///////////////////////////////// ///////////////////////////////// //Test 28 //requestUpdateSwitch should return true when given a block that contains a switch. Actual DB update checked in next test tempIBlock = tm.requestBlockInfo(15, "Red"); int oldDest1 = tempIBlock.SwitchDest1; tempIBlock.SwitchDest1 = tempIBlock.SwitchDest2; tempIBlock.SwitchDest2 = oldDest1; resBool = tm.requestUpdateSwitch(tempIBlock); tempIBlock = tm.requestBlockInfo(15, "Red"); if (resBool == true) { if (tempIBlock.SwitchDest1 != oldDest1) { pass++; message.Add("Pass: requestUpdateSwitch returned true and updated the database when given valid block"); } else { fail++; message.Add("Fail: requestUpdateSwitch returned true but failed to update database when given valid block"); } } else { fail++; message.Add("Fail: requestUpdateSwitch returned false when given valid block"); } //End Test 28 ///////////////////////////////// return(true); }
public void createEnvironment() { // Environment object _env = new SimulationEnvironment.SimulationEnvironment(); }
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; }
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; }
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(); var tm = new TrackModel.TrackModel(environment); ///////////////////////////////// //Test 1 //Check that RedLoaded is initially false if (tm.RedLoaded == false) { pass++; message.Add("Pass: RedLoaded is initially false"); } else { fail++; message.Add("Fail: RedLoaded was not initially false, as it should be prior to loading RedLine"); } //End test 1 ///////////////////////////////// ///////////////////////////////// //Test 2 //Check that GreenLoaded is initially false if (tm.GreenLoaded == false) { pass++; message.Add("Pass: GreenLoaded is initially false, as desired"); } else { fail++; message.Add("Fail: GreenLoaded was not initially false, as it should be prior to loading GreenLine"); } ///////////////////////////////// ///////////////////////////////// //Test 3 //provideInputFile returns false when given bad input file bool resBool=tm.provideInputFile("asdfawecxwe");/** Gee, Really hope this file doesnt exist*/ if (resBool == false) { pass++; message.Add("Pass: provideInputFile returns false when given bad file"); } else { fail++; message.Add("Fail: provideInputFile didn't return false when given an invalid filename"); } //End Test 3 ///////////////////////////////// ///////////////////////////////// //Test 4 //provideInputFile should return false when given a null argument resBool = tm.provideInputFile(null); if (resBool == false) { pass++; message.Add("Pass: provideInputFile returns false when given a null argument"); } else { fail++; message.Add("Fail: provideInputFile should return false when given a null argument"); } //End Test 4 ///////////////////////////////// ///////////////////////////////// //Test 5 //provideInputFile should return false when given a non-csv file resBool = tm.provideInputFile(@"..\..\red.bad");//An existent but non csv file if (resBool == false) { pass++; message.Add("Pass: provideInputFile returns false when given a non-csv file"); } else { fail++; message.Add("Fail: provideInputFile did not return false when given a non-csv file as expected"); } //End Test 5 ///////////////////////////////// ///////////////////////////////// //Test 6 //provideInputFile should return true when given a valid file resBool=tm.provideInputFile(@"..\..\red.csv"); if (resBool == true) { pass++; message.Add("Pass: provideInputFile returned true when given a valid, existing, and properly formatted file (red.csv)"); } else { fail++; message.Add("Pass: provideInputFile returned false when given a valid and proper file, expected val was true (red.csv)"); } //End Test 6 ///////////////////////////////// ///////////////////////////////// //Test 7 //provideInputFile should return true when given a valid file resBool = tm.provideInputFile(@"..\..\green.csv"); if (resBool == true) { pass++; message.Add("Pass: provideInputFile returned true when given a valid, existing, and properly formatted file (green.csv)"); } else { fail++; message.Add("Pass: provideInputFile returned false when given a valid and proper file, expected val was true (green.csv)"); } //End Test 7 ///////////////////////////////// ///////////////////////////////// //Test 8 //Check that RedLoaded property returns true after loading if (tm.RedLoaded) { pass++; message.Add("Pass: the RedLoaded Property shows that the red line has now been loaded"); } else { fail++; message.Add("Fail: the RedLoaded Property does not show that the red line has been loaded"); } //End Test 8 ///////////////////////////////// ///////////////////////////////// //Test 9 if (tm.GreenLoaded) { pass++; message.Add("Pass: The GreenLoaded Property shows that the green line has now been loaded"); } else { fail++; message.Add("Fail: The GreenLoaded Property does not show that the green line has been loaded"); } //End Test 9 ///////////////////////////////// ///////////////////////////////// //Test 10 //requestBlockInfo should return null when given a negative block number IBlock tempIBlock = tm.requestBlockInfo(-1, "Red"); if (tempIBlock == null) { pass++; message.Add("Pass: requestBlockInfo returned null when given a negative blockID"); } else { fail++; message.Add("Fail: requestBlockInfo returned a valid block when given negative blockID, expected val was null"); } //End Test 10 ///////////////////////////////// ///////////////////////////////// //Test 11 //requestBlockInfo should return null when given a blockID=0 tempIBlock = tm.requestBlockInfo(0, "Red"); if (tempIBlock != null) { pass++; message.Add("Pass: requestBlockInfo was able to retrieve the 0 block of a line"); } else { fail++; message.Add("Fail: requestBlockInfo returned null when given blockID=0, expected val was valid block"); } //End Test 11 ///////////////////////////////// ///////////////////////////////// //Test 12 //requestBlockInfo should return null when asked to retrieve an out-of-range block id tempIBlock = tm.requestBlockInfo(19191, "Red"); if (tempIBlock == null) { pass++; message.Add("Pass: requestBlockInfo returned null as expected when given an out of range block ID"); } else { fail++; message.Add("Fail: requestBlockInfo did not return null when given an out of range blockID, expected val was null"); } //End Test 12 ///////////////////////////////// ///////////////////////////////// //Test 13 //requestBlockInfo should return null when given a bad line string tempIBlock = tm.requestBlockInfo(0, "asdf"); if (tempIBlock == null) { pass++; message.Add("Pass: requestBlockInfo returned null when given an invalid line string"); } else { fail++; message.Add("Fail: requestBlockInfo did not return null when given an invalid line string"); } //End Test 13 ///////////////////////////////// ///////////////////////////////// //Test 14 //requestBlockInfo should return a valid block when asked to retrieve a basic block (without extra infrastructure) tempIBlock = tm.requestBlockInfo(1, "Red"); if (tempIBlock != null) { pass++; message.Add("Pass: requestBlockInfo successfully returned a basic block without extra infrastructure"); } else { fail++; message.Add("Fail: requestBlockInfo returned null when asked to retrieve a basic block without extra infrastructure"); } //End Test 14 ///////////////////////////////// ///////////////////////////////// //Test 15 //requestBlockInfo should return a valid block when asked to retrieve a more complex block (containing infrastructure such as switch, heater, etc). tempIBlock = tm.requestBlockInfo(27, "Red"); if (tempIBlock != null) { pass++; message.Add("Pass: requestBlockInfo successfully returned a complex block (with additional infra)"); } else { fail++; message.Add("Fail: requestBlockInfo returns null when asked for a more complex block (with additional infra)"); } //End Test 15 ///////////////////////////////// ///////////////////////////////// //Test 16 //requestUpdateBlock returns false when provided with a null value resBool=tm.requestUpdateBlock(null); if (resBool == false) { pass++; message.Add("Pass: requestUpdateBlock returns false when given a null value"); } else { fail++; message.Add("Fail: requestUpdateBlock returns true when given a null value, expected value is false"); } //End Test 16 ///////////////////////////////// ///////////////////////////////// //Test 17 //requestUpdateBlock returns false when provided with a block w/ ID=0 (no updating the yard) tempIBlock=tm.requestBlockInfo(0, "Red"); resBool = tm.requestUpdateBlock(tempIBlock); if (resBool == false) { pass++; message.Add("Pass: requestUpdateBlock returned false when attempting to update 0 block (yard)"); } else { fail++; message.Add("Fail: requestUpdateBlock returned true when attempting to update 0 block (yard), expected value was false"); } //End Test 17 ///////////////////////////////// ///////////////////////////////// //Test 18 //requestBlockUpdate should allow change of Health State tempIBlock=tm.requestBlockInfo(1,"Red"); //Store old state, and assign new state in a way that ensures oldState and newState are different var oldState = tempIBlock.State; if(oldState!=StateEnum.CircuitFailure) tempIBlock.State = StateEnum.CircuitFailure; else tempIBlock.State=StateEnum.BrokenTrackFailure; //Update the block resBool=tm.requestUpdateBlock(tempIBlock); //Re-request info from database tempIBlock=tm.requestBlockInfo(1,"Red"); if (resBool && tempIBlock.State != oldState) { pass++; } else if (!resBool && tempIBlock.State==oldState) { fail++; message.Add("Fail: requestUpdateBlock returnd a false value, when given a changed state, expected val was true"); } else { fail++; message.Add("Fail: requestUpdateBlock returned true, but failed to update the database"); } //End Test 18 ///////////////////////////////// ///////////////////////////////// //Test 19 //requestUpdateBlock should allow updating of heater state ////////////////////////////////// //THIS NEEDS IMPLEMENTED STILL //No blocks in the init file contain heaters by default //Should I assume that every block has a heater? //I prob want to write a method in the BLOCK object that lets you turn the heater on and off // ////////////////////////////////// //End Test 19 ///////////////////////////////// ///////////////////////////////// //Test 20 //requestUpdateBlock should return true but fail to update swith when asked to update switch information in db tempIBlock=tm.requestBlockInfo(1, "Red"); int oldSD1 = tempIBlock.SwitchDest1; tempIBlock.SwitchDest1 = tempIBlock.SwitchDest2; tempIBlock.SwitchDest2 = oldSD1; resBool=tm.requestUpdateBlock(tempIBlock); tempIBlock=tm.requestBlockInfo(1, "Red"); if (resBool == true && tempIBlock.SwitchDest1 == oldSD1) { pass++; message.Add("Pass: requestUpdateBlock did not update Switch state in database"); } else { fail++; message.Add("Fail: either the returned boolean was false, or the data was updated in the db."); } //End Test 20 ///////////////////////////////// ///////////////////////////////// //Test 21 //requestRouteInfo should return a null value when given a negative route ID IRouteInfo tempIRouteInfo=tm.requestRouteInfo(-1); if (tempIRouteInfo == null) { pass++; message.Add("Pass: requestRouteInfo returns null when given a negative routeID"); } else { fail++; message.Add("Fail: requestRouteInfo returned a Route when given a negative routeID, expected val was null"); } //End Test 21 ///////////////////////////////// ///////////////////////////////// //Test 22 //requestRouteInfo should return a null value when given a line other than 0 or 1 tempIRouteInfo = tm.requestRouteInfo(2); if (tempIRouteInfo == null) { pass++; message.Add("Pass: requestRouteInfo returns null when given an out of range routeID"); } else { fail++; message.Add("Fail: requestRouteInfo returned a Route when given an out of range route ID, expected val was null"); } //End Test 22 ///////////////////////////////// ///////////////////////////////// //Test 23 //requestRouteInfo returns a valid IRouteInfo object when given a line ID of 0 or 1 tempIRouteInfo = tm.requestRouteInfo(0); if (tempIRouteInfo != null) { pass++; message.Add("Pass: requestRouteInfo returns valid IRouteInfo when given valid lineID"); } else { fail++; message.Add("Fail: requestRouteInfo returns null when given valid lineID, expected val was null"); } //End Test 23 ///////////////////////////////// ///////////////////////////////// //Test 24 //requestTrackGrid should return null when given an invalid line ID IBlock[,] tempIBlockArr = tm.requestTrackGrid(-1); if (tempIBlockArr == null) { pass++; message.Add("Pass: requestTrackGrid returns null when given invalid line ID"); } else { fail++; message.Add("Fail: requestTrackGrid returns valid IBlock[,] when given invalid line id, expected value was null"); } //End Test 24 ///////////////////////////////// ///////////////////////////////// //Test 25 //requestTrackGrid should return valid IBlock[,] when given valid line ID tempIBlockArr = tm.requestTrackGrid(0); if (tempIBlockArr != null) { pass++; message.Add("Pass: requestTrackGrid returns valid IBlock[,] when given valid line id"); } else { fail++; message.Add("Fail: requestTrackGrid returns null when given valid line id, expected val was IBlock[,] object"); } //End Test 25 ///////////////////////////////// ///////////////////////////////// //Test 26 //requestUpdateSwitch should return false when given a null Block value resBool=tm.requestUpdateSwitch(null); if (resBool == false) { pass++; message.Add("Pass: requestUpdateSwitch returns false when given a null parameter"); } else { fail++; message.Add("Fail: requestUpdateSwitch returns true when given a null parameter, expected value was false"); } //End Test 26 ///////////////////////////////// ///////////////////////////////// //Test 27 //requestUpdateSwitch should return false when given a block that doesnt contain a switch tempIBlock=tm.requestBlockInfo(1, "Red"); resBool=tm.requestUpdateSwitch(tempIBlock); if (resBool == false) { pass++; message.Add("Pass: requestUpdateSwitch returns false when given a block without a switch"); } else { fail++; message.Add("Fail: requestUpdateSwitch returns true when given a block without a switch"); } //End Test 27 ///////////////////////////////// ///////////////////////////////// //Test 28 //requestUpdateSwitch should return true when given a block that contains a switch. Actual DB update checked in next test tempIBlock = tm.requestBlockInfo(15,"Red"); int oldDest1 = tempIBlock.SwitchDest1; tempIBlock.SwitchDest1 = tempIBlock.SwitchDest2; tempIBlock.SwitchDest2 = oldDest1; resBool=tm.requestUpdateSwitch(tempIBlock); tempIBlock = tm.requestBlockInfo(15, "Red"); if (resBool == true) { if (tempIBlock.SwitchDest1 != oldDest1) { pass++; message.Add("Pass: requestUpdateSwitch returned true and updated the database when given valid block"); } else { fail++; message.Add("Fail: requestUpdateSwitch returned true but failed to update database when given valid block"); } } else { fail++; message.Add("Fail: requestUpdateSwitch returned false when given valid block"); } //End Test 28 ///////////////////////////////// return true; }
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); }
public void createEnvironment() { // Environment object _env = new SimulationEnvironment.SimulationEnvironment(); }
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); }