public void Creation_ExpectSuccess() { //Arrange var controller = new TrafficMonitor { SystemTime = DateTime.Now }; //Assert Assert.IsTrue(controller.Lights.Count == 4); Assert.IsTrue(controller.Stages.Count == 3); Assert.IsTrue(controller.EventQueue.Count == 0); }
public void Start_GivenDefaultController_ExpectOneEventInEventQueue() { //Arrange var controller = new TrafficMonitor { SystemTime = DateTime.Now }; //Act controller.Start(); //Assert Assert.IsTrue(controller.EventQueue.Count == 1); }
public StringBuilder Export(int Interval = 0) { StringBuilder SB = new StringBuilder(); List <TrafficMonitor> ExportData = new List <TrafficMonitor>(); int RowCount = 0; DateTime FlightDate = DateTime.MinValue; //find the time of flight starting int LastFlightID = FlightID; if (DroneID > 0) { var Query = from d in db.MSTR_Drone where d.DroneId == DroneID select d.LastFlightID; var FoundFlightID = Query.FirstOrDefault(); if (FoundFlightID != null && FoundFlightID != 0) { LastFlightID = (int)FoundFlightID; } } var FlightDateQuery = from d in db.FlightMapDatas where d.FlightID == LastFlightID orderby d.CreatedTime descending select d.CreatedTime; var FoundFlightDate = FlightDateQuery.FirstOrDefault(); if (FoundFlightDate != null) { FlightDate = (DateTime)FoundFlightDate; } while (true) { RowCount++; Decimal FrameTime = RowCount * Interval * 60 * 1000; TrafficMonitor ThisData = (from d in db.TrafficMonitor where d.FlightID == FlightID && d.FrameTime >= FrameTime select d).FirstOrDefault(); if (ThisData == null) { break; } ExportData.Add(ThisData); } //get the last data TrafficMonitor LastData = (from d in db.TrafficMonitor where d.FlightID == FlightID orderby d.FrameTime descending select d).FirstOrDefault(); if (LastData != null) { ExportData.Add(LastData); } SB.AppendLine("Time,Location," + "Leg1Straight,Leg1UTurn,Leg1Left,Leg1Right," + "Leg2Straight,Leg2UTurn,Leg2Left,Leg2Right," + "Leg3Straight,Leg3UTurn,Leg3Left,Leg3Right," + "Leg4Straight,Leg4UTurn,Leg4Left,Leg4Right"); TrafficMonitor LastExportRow = null; foreach (var Data in ExportData) { var ProcessedRow = Data; if (LastExportRow != null) { ProcessedRow = Data - LastExportRow; } DateTime ExportDate = FlightDate.AddMilliseconds((Double)Data.FrameTime); SB.AppendLine(ExportDate.ToString(@"yyyy-MM-dd hh\:mm\:ss") + "," + (Location == null ? "N/A" : Location.GetLocation(false)) + "," + $"{ProcessedRow.DD},{ProcessedRow.DU},{ProcessedRow.DR},{ProcessedRow.DL}," + $"{ProcessedRow.LL},{ProcessedRow.LR},{ProcessedRow.LD},{ProcessedRow.LU}," + $"{ProcessedRow.UU},{ProcessedRow.UD},{ProcessedRow.UL},{ProcessedRow.UR}," + $"{ProcessedRow.RR},{ProcessedRow.RL},{ProcessedRow.RU},{ProcessedRow.RD}" ); LastExportRow = Data.Copy(); } return(SB); }
public LogIn() { InitializeComponent(); initializeConnection = new Account(); trafficMonitor = TrafficMonitor.Instance; }