<commit_before>﻿namespace ScamperTracerouteParser.UnitTests
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System;
    using System.Net;

    [TestClass]
    public class TestParser
    {
        [DeploymentItem(@"App_Data\ScamperSample1.txt", @"App_Data")]
        [TestMethod]
        public void TestFieldExtraction()
        {
            ScamperTraceroute currentTraceroute = null;

            foreach (var traceroute in TracerouteTextDumpParser.ParseFile(@"App_Data\ScamperSample1.txt"))
            {
                currentTraceroute = traceroute;
            }

            Assert.AreEqual(IPAddress.Parse("172.16.17.32"), currentTraceroute.Source);
            Assert.AreEqual(IPAddress.Parse("192.168.3.11"), currentTraceroute.Destination);
            Assert.AreEqual(7, currentTraceroute.ListId);
            Assert.AreEqual(5520, currentTraceroute.CycleId);
            Assert.AreEqual(1489105699, currentTraceroute.Timestamp);
            Assert.AreEqual(new DateTime(2017, 3, 10, 0, 28, 19), currentTraceroute.TraceStartDateTime);
            Assert.AreEqual(DestReplied.NotReplied, currentTraceroute.DestinationReplied);
            Assert.AreEqual(0, currentTraceroute.DestinationRTT);
            Assert.AreEqual(0, currentTraceroute.RequestTTL);
            Assert.AreEqual(0, currentTraceroute.ReplyTTL);
            Assert.AreEqual(HaltReason.GapDetected, currentTraceroute.HaltReason);
            Assert.AreEqual("0", currentTraceroute.HaltReasonData);
            Assert.AreEqual(PathComplete.Incomplete, currentTraceroute.PathComplete);

            Assert.AreEqual(14, currentTraceroute.Hops.Count);

            var lastHop = currentTraceroute.Hops[13];
            Assert.AreEqual(2, lastHop.IPs.Count);

            var lastIPInfoInHop = lastHop.IPs[1];
            Assert.AreEqual(IPAddress.Parse("10.246.250.98"), lastIPInfoInHop.IP);
            Assert.AreEqual(246.193m, lastIPInfoInHop.RTT);
            Assert.AreEqual(3, lastIPInfoInHop.Tries);
        }

        [DeploymentItem(@"App_Data\ScamperSample1.txt", @"App_Data")]
        [TestMethod]
        public void TestHaltReasonFailure()
        {
            var line = "T	192.168.3.11	172.16.58.3	7	5512	1488851553	N	0	0	0	?	0	I";

            var traceroute = TracerouteTextDumpParser.ParseLine(line);

            Assert.AreEqual(HaltReason.Unknown, traceroute.HaltReason);
        }
    }
}<commit_msg>Added latency neighbors check in Halt Reason unit test<commit_after>﻿namespace ScamperTracerouteParser.UnitTests
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System;
    using System.Net;

    [TestClass]
    public class TestParser
    {
        [DeploymentItem(@"App_Data\ScamperSample1.txt", @"App_Data")]
        [TestMethod]
        public void TestFieldExtraction()
        {
            ScamperTraceroute currentTraceroute = null;

            foreach (var traceroute in TracerouteTextDumpParser.ParseFile(@"App_Data\ScamperSample1.txt"))
            {
                currentTraceroute = traceroute;
            }

            Assert.AreEqual(IPAddress.Parse("172.16.17.32"), currentTraceroute.Source);
            Assert.AreEqual(IPAddress.Parse("192.168.3.11"), currentTraceroute.Destination);
            Assert.AreEqual(7, currentTraceroute.ListId);
            Assert.AreEqual(5520, currentTraceroute.CycleId);
            Assert.AreEqual(1489105699, currentTraceroute.Timestamp);
            Assert.AreEqual(new DateTime(2017, 3, 10, 0, 28, 19), currentTraceroute.TraceStartDateTime);
            Assert.AreEqual(DestReplied.NotReplied, currentTraceroute.DestinationReplied);
            Assert.AreEqual(0, currentTraceroute.DestinationRTT);
            Assert.AreEqual(0, currentTraceroute.RequestTTL);
            Assert.AreEqual(0, currentTraceroute.ReplyTTL);
            Assert.AreEqual(HaltReason.GapDetected, currentTraceroute.HaltReason);
            Assert.AreEqual("0", currentTraceroute.HaltReasonData);
            Assert.AreEqual(PathComplete.Incomplete, currentTraceroute.PathComplete);

            Assert.AreEqual(14, currentTraceroute.Hops.Count);

            var lastHop = currentTraceroute.Hops[13];
            Assert.AreEqual(2, lastHop.IPs.Count);

            var lastIPInfoInHop = lastHop.IPs[1];
            Assert.AreEqual(IPAddress.Parse("10.246.250.98"), lastIPInfoInHop.IP);
            Assert.AreEqual(246.193m, lastIPInfoInHop.RTT);
            Assert.AreEqual(3, lastIPInfoInHop.Tries);
        }

        [DeploymentItem(@"App_Data\ScamperSample1.txt", @"App_Data")]
        [TestMethod]
        public void TestHaltReasonFailure()
        {
            var line = "T	192.168.3.11	172.16.58.3	7	5512	1488851553	N	0	0	0	?	0	I";

            var traceroute = TracerouteTextDumpParser.ParseLine(line);

            Assert.AreEqual(HaltReason.Unknown, traceroute.HaltReason);

            var neighborPairs = traceroute.FindLatencyNeighbors();
            Assert.AreEqual(0, neighborPairs.Count);
        }
    }
}
{'fraction_non_alphanumeric': 0.103, 'fraction_numerical': 0.0446, 'mean_word_length': 2.712694877505568, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 10, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6745076', 'n_tokens_mistral': 1673, 'n_tokens_neox': 1510, 'n_words': 215}