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 RequestFrame(string primaryTrackController, TestingTrackController tc) { InitializeComponent(); _ptc = primaryTrackController; _ptco = tc; _ptco.TransferRequest += new EventHandler<EventArgs>(_ptco_TransferRequest); _txtPrimaryTrackController.Text = _ptc; _txtBlockID.ReadOnly = true; _txtDateTime.ReadOnly = true; _txtPrimaryTrackController.ReadOnly = true; _txtRequestType.ReadOnly = true; _txtTrackControllerID.ReadOnly = true; _txtTrainAuthority.ReadOnly = true; _txtTrainID.ReadOnly = true; _txtTrainRoute.ReadOnly = true; _txtTrainSpeed.ReadOnly = true; }
public RequestFrame(string primaryTrackController, TestingTrackController tc) { InitializeComponent(); _ptc = primaryTrackController; _ptco = tc; _ptco.TransferRequest += new EventHandler <EventArgs>(_ptco_TransferRequest); _txtPrimaryTrackController.Text = _ptc; _txtBlockID.ReadOnly = true; _txtDateTime.ReadOnly = true; _txtPrimaryTrackController.ReadOnly = true; _txtRequestType.ReadOnly = true; _txtTrackControllerID.ReadOnly = true; _txtTrainAuthority.ReadOnly = true; _txtTrainID.ReadOnly = true; _txtTrainRoute.ReadOnly = true; _txtTrainSpeed.ReadOnly = true; }
public bool DoTest(out int pass, out int fail, out List <string> message) { //local pass = 0; fail = 0; message = new List <string>(); //global for events _pass = 0; _fail = 0; _message = new List <string>(); redRequests = new bool[7] { false, false, false, false, false, false, false }; greenRequests = new bool[7] { false, false, false, false, false, false, false }; //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, false); _green = new TestingTrackController(1, _trackMod, _env, false); //hook to environment _env.PrimaryTrackControllerRed = _red; _red.TransferRequest += new EventHandler <EventArgs>(_red_TransferRequest); _env.PrimaryTrackControllerGreen = _green; _green.TransferRequest += new EventHandler <EventArgs>(_green_TransferRequest); _env.TrackModel = _trackMod; //creating office instance _ctc = new CTCOffice.CTCOffice(_env, _red, _green); if (_ctc != null) { pass++; message.Add("CTC Object Secessfully Created"); } else { fail++; message.Add("CTC Object Not Secessfully Created"); } _env.CTCOffice = _ctc; _ctc.StartAutomation += new EventHandler <EventArgs>(_ctc_StartAutomation); _ctc.StopAutomation += new EventHandler <EventArgs>(_ctc_StopAutomation); _ctc.LoadData += new EventHandler <EventArgs>(_ctc_LoadData); _ctc.MessagesReady += new EventHandler <EventArgs>(_ctc_MessagesReady); _ctc.UnlockLogin += new EventHandler <EventArgs>(_ctc_UnlockLogin); _ctc.UpdatedData += new EventHandler <EventArgs>(_ctc_UpdatedData); _env.StartTick(); _trackMod.ThrowTrackChanged(); if (_env.CTCOffice != null) { pass++; message.Add("CTC Office Added to Environment"); #region Login Testing //Test Improper Login if (!_ctc.Login("me", "42")) { pass++; message.Add("PASS: Operator has invalid credentials"); } else { fail--; message.Add("FAIL: Operator has invlaid credentials"); } //Test Operator Auth (invalid creds) if (!_ctc.IsAuth()) { pass++; message.Add("PASS: Op Auth (Lockout)"); } else { fail++; message.Add("FAIL: Op Auth (Lockout)"); } //Test Proper Login if (_ctc.Login("root", "admin")) { pass++; message.Add("PASS: Operator Login"); } else { fail--; message.Add("FAIL: Operator Login"); } //Test Operator Auth (invalid creds) if (_ctc.IsAuth()) { pass++; message.Add("PASS: Op Auth"); } else { fail++; message.Add("FAIL: Op Auth"); } //Logout //Always returns true pass++; message.Add("PASS: Logout (always true)"); #endregion //Populate Track -> void function.. always passes unit test pass++; message.Add("PASS: PopulateTrack() (always true unless exception is generated)"); //call for start scheduling _ctc.StartScheduling(); _ctc.StopScheduling(); #region Test Get Line if (_ctc.GetLine(0) != null) { pass++; message.Add("PASS: GetLine(0) -> Red."); } else { fail++; message.Add("Fail: GetLine(0) -> Red."); } if (_ctc.GetLine(1) != null) { pass++; message.Add("PASS: GetLine(1) -> Green."); } else { fail++; message.Add("Fail: GetLine(1) -> Green."); } if (_ctc.GetLine(2) == null) { pass++; message.Add("PASS: GetLine(2) -> null."); } else { fail++; message.Add("Fail: GetLine(0) -> null."); } #endregion //Cannot test private functions (including Line ID functions) //RequestTypes.AssignTrainRoute //RequestTypes.SetTrainAuthority //RequestTypes.SetTrainOOS //RequestTypes.SetTrainSpeed ////RequestTypes.TrackControllerData //RequestTypes.TrackMaintenanceClose //RequestTypes.TrackMaintenanceOpen TestingBlock redBlock = new TestingBlock("Red", 0, 0, 0, null, true, false, false, false, false, false, StateEnum.Healthy); TestingBlock greenBlock = new TestingBlock("Green", 0, 0, 0, null, true, false, false, false, false, false, StateEnum.Healthy); _ctc.assignTrainRouteRequest(1, 0, null, redBlock); _ctc.setTrainAuthorityRequest(1, 0, 50, redBlock); _ctc.setTrainOutOfServiceRequest(1, 0, redBlock); _ctc.setTrainSpeedRequest(1, 0, 50, redBlock); _ctc.closeTrackBlockRequest(0, redBlock); _ctc.openTrackBlockRequest(0, redBlock); _ctc.assignTrainRouteRequest(1, 1, null, greenBlock); _ctc.setTrainAuthorityRequest(1, 1, 50, greenBlock); _ctc.setTrainOutOfServiceRequest(1, 1, greenBlock); _ctc.setTrainSpeedRequest(1, 1, 50, greenBlock); _ctc.closeTrackBlockRequest(1, greenBlock); _ctc.openTrackBlockRequest(1, greenBlock); //dispatch train handled in GUI Tester //cannot test handleResponse. No actual case to test } else { fail++; message.Add("CTC Office Not Added to Environment"); } //add event handler tests pass = pass + _pass; fail = fail + _fail; message.AddRange(_message); return(true); }
public bool DoTest(out int pass, out int fail, out List<string> message) { //local pass = 0; fail = 0; message = new List<string>(); //global for events _pass = 0; _fail = 0; _message = new List<string>(); redRequests = new bool[7] { false, false, false, false, false, false, false }; greenRequests = new bool[7] { false, false, false, false, false, false, false }; //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, false); _green = new TestingTrackController(1, _trackMod, _env, false); //hook to environment _env.PrimaryTrackControllerRed = _red; _red.TransferRequest += new EventHandler<EventArgs>(_red_TransferRequest); _env.PrimaryTrackControllerGreen = _green; _green.TransferRequest += new EventHandler<EventArgs>(_green_TransferRequest); _env.TrackModel = _trackMod; //creating office instance _ctc = new CTCOffice.CTCOffice(_env, _red, _green); if (_ctc != null) { pass++; message.Add("CTC Object Secessfully Created"); } else { fail++; message.Add("CTC Object Not Secessfully Created"); } _env.CTCOffice = _ctc; _ctc.StartAutomation += new EventHandler<EventArgs>(_ctc_StartAutomation); _ctc.StopAutomation += new EventHandler<EventArgs>(_ctc_StopAutomation); _ctc.LoadData += new EventHandler<EventArgs>(_ctc_LoadData); _ctc.MessagesReady += new EventHandler<EventArgs>(_ctc_MessagesReady); _ctc.UnlockLogin += new EventHandler<EventArgs>(_ctc_UnlockLogin); _ctc.UpdatedData += new EventHandler<EventArgs>(_ctc_UpdatedData); _env.StartTick(); _trackMod.ThrowTrackChanged(); if (_env.CTCOffice != null) { pass++; message.Add("CTC Office Added to Environment"); #region Login Testing //Test Improper Login if (!_ctc.Login("me", "42")) { pass++; message.Add("PASS: Operator has invalid credentials"); } else { fail--; message.Add("FAIL: Operator has invlaid credentials"); } //Test Operator Auth (invalid creds) if (!_ctc.IsAuth()) { pass++; message.Add("PASS: Op Auth (Lockout)"); } else { fail++; message.Add("FAIL: Op Auth (Lockout)"); } //Test Proper Login if (_ctc.Login("root", "admin")) { pass++; message.Add("PASS: Operator Login"); } else { fail--; message.Add("FAIL: Operator Login"); } //Test Operator Auth (invalid creds) if (_ctc.IsAuth()) { pass++; message.Add("PASS: Op Auth"); } else { fail++; message.Add("FAIL: Op Auth"); } //Logout //Always returns true pass++; message.Add("PASS: Logout (always true)"); #endregion //Populate Track -> void function.. always passes unit test pass++; message.Add("PASS: PopulateTrack() (always true unless exception is generated)"); //call for start scheduling _ctc.StartScheduling(); _ctc.StopScheduling(); #region Test Get Line if (_ctc.GetLine(0) != null) { pass++; message.Add("PASS: GetLine(0) -> Red."); } else { fail++; message.Add("Fail: GetLine(0) -> Red."); } if (_ctc.GetLine(1) != null) { pass++; message.Add("PASS: GetLine(1) -> Green."); } else { fail++; message.Add("Fail: GetLine(1) -> Green."); } if (_ctc.GetLine(2) == null) { pass++; message.Add("PASS: GetLine(2) -> null."); } else { fail++; message.Add("Fail: GetLine(0) -> null."); } #endregion //Cannot test private functions (including Line ID functions) //RequestTypes.AssignTrainRoute //RequestTypes.SetTrainAuthority //RequestTypes.SetTrainOOS //RequestTypes.SetTrainSpeed ////RequestTypes.TrackControllerData //RequestTypes.TrackMaintenanceClose //RequestTypes.TrackMaintenanceOpen TestingBlock redBlock = new TestingBlock("Red", 0, 0, 0, null, true, false, false, false, false, false, StateEnum.Healthy); TestingBlock greenBlock = new TestingBlock("Green", 0, 0, 0, null, true, false, false, false, false, false, StateEnum.Healthy); _ctc.assignTrainRouteRequest(1, 0, null, redBlock); _ctc.setTrainAuthorityRequest(1, 0, 50, redBlock); _ctc.setTrainOutOfServiceRequest(1, 0, redBlock); _ctc.setTrainSpeedRequest(1, 0, 50, redBlock); _ctc.closeTrackBlockRequest(0, redBlock); _ctc.openTrackBlockRequest(0, redBlock); _ctc.assignTrainRouteRequest(1, 1, null, greenBlock); _ctc.setTrainAuthorityRequest(1, 1, 50, greenBlock); _ctc.setTrainOutOfServiceRequest(1, 1, greenBlock); _ctc.setTrainSpeedRequest(1, 1, 50, greenBlock); _ctc.closeTrackBlockRequest(1, greenBlock); _ctc.openTrackBlockRequest(1, greenBlock); //dispatch train handled in GUI Tester //cannot test handleResponse. No actual case to test } else { fail++; message.Add("CTC Office Not Added to Environment"); } //add event handler tests pass = pass + _pass; fail = fail + _fail; message.AddRange(_message); return true; }