public void UutFileLogLoginFile() { string file = "log.txt"; string tag = "AB408"; List <string> involved = new List <string>(); involved.Add(tag); DateTime now = new DateTime(); now = DateTime.Now; Event e = new Event(now, "Entered Monitored Area", "Notification", involved); List <Event> events = new List <Event>(); events.Add(e); _uut.Log(events); string[] text = File.ReadAllLines(file); string[] input = text[0].Split(' '); string time = input[0] + " " + input[1]; string loggedTag = input[input.Length - 1]; Assert.That(time.Equals(now.ToString())); Assert.That(loggedTag.Equals(tag)); }
public List <Event> DetectEvents(List <Track> tracks) { events = new List <Event>(); if (oldTracks != null) { // Detect tracks leaving monitored area for (int i = 0; i < tracks.Count; i++) { for (int j = 0; j < oldTracks.Count; j++) { if (tracks[i].Tag == oldTracks[j].Tag) { // if flight entered monitored area if (tracks[i].InArea == true && oldTracks[j].InArea == false) { List <string> involved = new List <string>(); involved.Add(tracks[i].Tag); events.Add(new Event(tracks[i].Time, "Entered monitored area", "Notification", involved)); } // if flight left monitored area if (tracks[i].InArea == false && oldTracks[j].InArea == true) { List <string> involved = new List <string>(); involved.Add(tracks[i].Tag); events.Add(new Event(tracks[i].Time, "Left monitored area", "Notification", involved)); } // if flight is in a conflict if (tracks[i].Conflicts != null) { for (int k = 0; k < tracks[i].Conflicts.Count; k++) { events.Add(new Event(tracks[i].Time, "Is in a conflict with Flight", "Warning", tracks[i].Conflicts)); } } } } } // Detect conflicts // clear oldtracks and events oldTracks.Clear(); } // Save local copy of tracks for next iteration for (int i = 0; i < tracks.Count; i++) { oldTracks.Add(tracks[i]); } //Log if (events.Count > 0) { _fileLog.Log(events); } // return events return(events); }