Exemplo n.º 1
0
        public void OneMoreNewSeparationEvent_ReceiveEvent_LogEvent()
        {
            // Create 1 separation args and raise event with it
            var separationEvent = new SeparationEventArgs(new SeparationEventObject("Tag123",
                                                                                    "Tag456",
                                                                                    DateTime.ParseExact("20180412111111111", "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture)));

            _checker.NewSeperationEvents += Raise.EventWith(separationEvent);

            // Create a second separation args and raise event with it
            separationEvent = new SeparationEventArgs(new SeparationEventObject("Tag789",
                                                                                "TagABC",
                                                                                DateTime.ParseExact("20180412111111111", "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture)));
            _checker.NewSeperationEvents += Raise.EventWith(separationEvent);

            // Open file
            using (File.OpenRead(FilePath))
            {
                // Read the last file into variable
                var lastLine = File.ReadLines(FilePath).Last();

                // Check that the last line matches the newest logged sep. args.
                Assert.That(lastLine,
                            Is.EqualTo("Separation occured at 12-04-2018 11:11:11 between tracks: Tag789, TagABC"));
            }
        }
Exemplo n.º 2
0
 public void RenderSeparationEvents(object sender, SeparationEventArgs e)
 {
     Dispatcher.BeginInvoke(new Action(() =>
     {
         ListViewSeparationEvents.ItemsSource = e.SeparationEvents;
     }));
 }
Exemplo n.º 3
0
        public void Ctor_TestGetMethod_ContainsSameAsInserted()
        {
            HashSet <ISeparationEvent> toInsertIntoSeparationsEvent = new HashSet <ISeparationEvent>();
            SeparationEventArgs        uut = new SeparationEventArgs(toInsertIntoSeparationsEvent);

            Assert.That(uut.SeparationEvents, Is.EqualTo(toInsertIntoSeparationsEvent));
        }
        public void LogSeparationToConsole(object sender, SeparationEventArgs separationEvent)
        {
            var separationString = $"{separationEvent.Track1} og {separationEvent.Track2} er på kollisionskurs\n" +
                                   $"Timestamp: {separationEvent.TimeOfOccurence} \n" +
                                   "Mayday mayday";

            Console.WriteLine(separationString);
        }
Exemplo n.º 5
0
        public void Ctor_AddToList_BothListAreStillIdentical()
        {
            HashSet <ISeparationEvent> toInsertIntoSeparationsEvent = new HashSet <ISeparationEvent>();
            SeparationEventArgs        uut = new SeparationEventArgs(toInsertIntoSeparationsEvent);

            uut.SeparationEvents.Add(new SeparationEvent("Tag1TT", "Tag2TT", DateTime.Now));

            Assert.That(uut.SeparationEvents, Is.EqualTo(toInsertIntoSeparationsEvent));
        }
Exemplo n.º 6
0
        public void LogSeparation(object sender, SeparationEventArgs separationEvent)
        {
            var xmlDocument = XDocument.Load(_location + "Separation.xml");
            var root        = xmlDocument.Root;

            root.Add(ConvertToXmlElement(separationEvent.Track1, separationEvent.Track2,
                                         separationEvent.TimeOfOccurence));
            xmlDocument.Save(_location + "Separation.xml");
        }
Exemplo n.º 7
0
        public void SetUp()
        {
            _checker = Substitute.For <ISeperationEventChecker>();
            _uut     = new LogSeparationEvent(_checker);

            // Clearing variable for eventhandling
            _receivedArgs = null;

            // Assigning to event and saving the args in variable
            _checker.NewSeperationEvents += (o, args) => { _receivedArgs = args; };
        }
        public void SetUp()
        {
            _uut            = new SeparationXmlLogging();
            tag1            = "ABC123";
            tag2            = "ABC234";
            timeOfOccurence = new DateTime(2000, 1, 1);
            formatted       = timeOfOccurence.ToString("yyyy-MM-ddTHH:mm:ssK");

            earg = new SeparationEventArgs();
            earg.TimeOfOccurence = timeOfOccurence;
            earg.Track1          = tag1;
            earg.Track2          = tag2;
        }
Exemplo n.º 9
0
        public void SetUp()
        {
            _listOfTracks = new List <TrackObject>();

            // Create tracks
            _track1 = new TrackObject("Tag123", 70000, 70000, 1000, DateTime.ParseExact("20180412111111111", "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture));
            _track2 = new TrackObject("Tag456", 68000, 68000, 800, DateTime.ParseExact("20180412111111111", "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture));
            _track3 = new TrackObject("Tag789", 89000, 89000, 5000, DateTime.ParseExact("20180412111111111", "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture));
            _track4 = new TrackObject("TagABC", 72000, 72000, 1200, DateTime.ParseExact("20180412111111111", "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture));

            // Clear args
            _receivedArgs = null;
            _newArgs      = null;

            _uut = new CheckForSeparationEvent();

            // Assign to events and save the arguments the events are raised with
            _uut.SeperationEvents += (o, args) => {
                _receivedArgs = args;
            };
            _uut.NewSeperationEvents += (o, args) => { _newArgs = args; };
        }
Exemplo n.º 10
0
        public void OneNewSeparationEvent_ReceiveEvent_LogEvent()
        {
            // Create event args
            var separationEvent = new SeparationEventArgs(new SeparationEventObject("Tag123",
                                                                                    "Tag456",
                                                                                    DateTime.ParseExact("20180412111111111", "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture)));

            // Raise with event
            _checker.NewSeperationEvents += Raise.EventWith(separationEvent);

            string lastLine;

            // Open file
            using (File.OpenRead(FilePath))
            {
                // Read the last line from file into variable
                lastLine = File.ReadLines(FilePath).Last();
            }

            // Checking that the newest added line matches the expected
            Assert.That(lastLine, Is.EqualTo("Separation occured at 12-04-2018 11:11:11 between tracks: Tag123, Tag456"));
        }
Exemplo n.º 11
0
        public void OneMoreNewSeparationEvent_LogEvent_LogOnCorrectPlace()
        {
            // Variables to contain the number of lines before and after logging new separation
            int initialLines;
            int endingLines;

            if (File.Exists(FilePath))
            {
                // Open stream
                using (File.OpenRead(FilePath))
                {
                    // Count number of lines and save
                    initialLines = File.ReadLines(FilePath).Count();
                }
            }
            else
            {
                initialLines = 0;
            }

            // Create event args and raise event with it
            var separationEvent = new SeparationEventArgs(new SeparationEventObject("Tag123",
                                                                                    "Tag456",
                                                                                    DateTime.ParseExact("20180412111111111", "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture)));

            _checker.NewSeperationEvents += Raise.EventWith(separationEvent);

            // Open stream
            using (File.OpenRead(FilePath))
            {
                // Count number of lines and save
                endingLines = File.ReadLines(FilePath).Count();
            }

            // Check that the number of lines is increased by one
            Assert.That(endingLines, Is.EqualTo(initialLines + 1));
        }
 private void _checker_SeperationEvents(object sender, SeparationEventArgs e)
 {
     _separationArgs = e;
 }
Exemplo n.º 13
0
 public void LogSeparationEvent(object o, SeparationEventArgs arg)
 {
     _fileWriter.WriteToFile(_loggingPath, arg.SeperationNote);
 }
Exemplo n.º 14
0
 public void CollisionAvoidedEventHandler(object sender, SeparationEventArgs e)
 {
     AircraftsColliding.Remove(e);
 }
Exemplo n.º 15
0
 public void CollisionEventHandler(object sender, SeparationEventArgs e)
 {
     AircraftsColliding.Add(e);
 }
 public void LogSeparationEvent(object o, SeparationEventArgs arg)
 {
     Console.WriteLine(arg.SeperationNote);
 }
Exemplo n.º 17
0
        public void SeparationHandler(object obj, SeparationEventArgs args)
        {
            var seperation = args.Separation;

            LogSeperation(seperation);
        }
 private void _checker_FinishedSeperationEvents(object sender, SeparationEventArgs e)
 {
     _finishedSeparationArgs = e;
 }
Exemplo n.º 19
0
        public void ReceiverWarningRaised(object sender, SeparationEventArgs e)
        {
            string str = String.Format("Collision event; {0}; {1}; {2}", e.a1.Tag, e.a2.Tag, e.a1.TimeStamp);

            _fileLogger.WriteToFile(str);
        }