Exemplo n.º 1
0
        public void TestAuthCnameQuery()
        {
            var       mockedTransport = GetMockedTransport();
            IResolver resolver        = new Resolver(mockedTransport.Object, testCache);

            var expected = new []
            {
                new CNameRecord
                {
                    Class = RecordClass.In,
                    CName = "fd-fp3.wg1.b.yahoo.com.",
                    Name  = "www.yahoo.com.",
                    Ttl   = 300,
                    Type  = RecordType.CNameRecord,
                },
            };

            var actual = resolver.AuthoratativeQuery("www.yahoo.com", RecordType.CNameRecord, new IPEndPoint(IPAddress.Parse("127.0.0.1"), 53));

            Assert.AreEqual(true, actual.Header.AuthoritativeAnswer, "Should have returned from SOA");
            AssertEquality(expected, actual.Answers.ToCNameCollection());

            //Test Caching
            mockedTransport.Setup(tr => tr.SendRequest(It.IsAny <IMessage>(), It.IsAny <IPEndPoint>(), It.IsAny <int>()))
            .Returns(new DNS.MessageingConcretes.Message());

            expected = actual.Answers.ToCNameCollection().ToArray();
            actual   = resolver.AuthoratativeQuery("www.yahoo.com", RecordType.CNameRecord, new IPEndPoint(IPAddress.Parse("127.0.0.1"), 53));
            Assert.AreEqual(false, actual.Header.AuthoritativeAnswer, "Should have returned from Cache");
            AssertEquality(expected, actual.Answers.ToCNameCollection());
        }
Exemplo n.º 2
0
        public void TestAuthQueryMxRecord()
        {
            var       mockedTransport = GetMockedTransport();
            IResolver resolver        = new Resolver(mockedTransport.Object, testCache);

            var expected = new []
            {
                new MxRecord
                {
                    Name       = "yahoo.com.",
                    Class      = RecordClass.In,
                    Ttl        = 1800,
                    Type       = RecordType.MxRecord,
                    Preference = 1,
                    Exchanger  = "mta6.am0.yahoodns.net.",
                },
                new MxRecord
                {
                    Name       = "yahoo.com.",
                    Class      = RecordClass.In,
                    Ttl        = 1800,
                    Type       = RecordType.MxRecord,
                    Preference = 1,
                    Exchanger  = "mta7.am0.yahoodns.net.",
                },
                new MxRecord
                {
                    Name       = "yahoo.com.",
                    Class      = RecordClass.In,
                    Ttl        = 1800,
                    Type       = RecordType.MxRecord,
                    Preference = 1,
                    Exchanger  = "mta5.am0.yahoodns.net.",
                },
            };

            var actual = resolver.AuthoratativeQuery("yahoo.com", RecordType.MxRecord, new IPEndPoint(IPAddress.Parse("127.0.0.1"), 53));

            Assert.AreEqual(true, actual.Header.AuthoritativeAnswer, "Should have returned from SOA");
            AssertEquality(expected, actual.Answers.ToMxCollection());

            //Test Caching
            mockedTransport.Setup(tr => tr.SendRequest(It.IsAny <IMessage>(), It.IsAny <IPEndPoint>(), It.IsAny <int>()))
            .Returns(new DNS.MessageingConcretes.Message());

            expected = actual.Answers.ToMxCollection().ToArray();
            actual   = resolver.AuthoratativeQuery("yahoo.com", RecordType.MxRecord, new IPEndPoint(IPAddress.Parse("127.0.0.1"), 53));
            Assert.AreEqual(false, actual.Header.AuthoritativeAnswer, "Should have returned from Cache");
            AssertEquality(expected, actual.Answers.ToMxCollection());
        }
Exemplo n.º 3
0
        public void TestAuthQueryARecord()
        {
            var       mockedTransport = GetMockedTransport();
            IResolver resolver        = new Resolver(mockedTransport.Object, testCache);

            var expected = new []
            {
                new ARecord
                {
                    Name    = "yahoo.com.",
                    Class   = RecordClass.In,
                    Ttl     = 1800,
                    Type    = RecordType.ARecord,
                    Address = IPAddress.Parse("206.190.36.45"),
                },
                new ARecord
                {
                    Name    = "yahoo.com.",
                    Class   = RecordClass.In,
                    Ttl     = 1800,
                    Type    = RecordType.ARecord,
                    Address = IPAddress.Parse("98.139.183.24"),
                },
                new ARecord
                {
                    Name    = "yahoo.com.",
                    Class   = RecordClass.In,
                    Ttl     = 1800,
                    Type    = RecordType.ARecord,
                    Address = IPAddress.Parse("98.138.253.109"),
                },
            };

            var actual = resolver.AuthoratativeQuery("yahoo.com", RecordType.ARecord, new IPEndPoint(IPAddress.Parse("127.0.0.1"), 53));

            Assert.AreEqual(true, actual.Header.AuthoritativeAnswer, "Should have returned from SOA");
            AssertEquality(expected, actual.Answers.ToACollection());

            //Test Caching
            mockedTransport.Setup(tr => tr.SendRequest(It.IsAny <IMessage>(), It.IsAny <IPEndPoint>(), It.IsAny <int>()))
            .Returns(new DNS.MessageingConcretes.Message());

            expected = actual.Answers.ToACollection().ToArray();
            actual   = resolver.AuthoratativeQuery("yahoo.com", RecordType.ARecord, new IPEndPoint(IPAddress.Parse("127.0.0.1"), 53));
            Assert.AreEqual(false, actual.Header.AuthoritativeAnswer, "Should have returned from Cache");
            AssertEquality(expected, actual.Answers.ToACollection());
        }