Inheritance: IResourceRecord
Ejemplo n.º 1
0
        public void RequestWithHeaderAndResourceRecords()
        {
            Header header = new Header();
            header.Response = true;

            Domain domain = new Domain(Helper.GetArray("www", "google", "com"));
            Question question = new Question(domain, RecordType.A, RecordClass.IN);

            Domain domain1 = new Domain(Helper.GetArray("www", "google", "com"));
            ResourceRecord record1 = new ResourceRecord(domain1, Helper.GetArray<byte>(3, 119, 119, 119, 0),
                RecordType.CNAME, RecordClass.IN, TimeSpan.FromSeconds(1));

            Domain domain2 = new Domain(Helper.GetArray("dr", "dk"));
            ResourceRecord record2 = new ResourceRecord(domain2, Helper.GetArray<byte>(1, 1, 1, 1),
                RecordType.A, RecordClass.ANY, TimeSpan.FromSeconds(0));

            Domain domain3 = new Domain(Helper.GetArray("www"));
            ResourceRecord record3 = new ResourceRecord(domain3, Helper.GetArray<byte>(192, 12),
                RecordType.CNAME, RecordClass.ANY, TimeSpan.FromSeconds(1));

            Response response = new Response(header,
                Helper.GetList(question),
                Helper.GetList<IResourceRecord>(record1),
                Helper.GetList<IResourceRecord>(record2),
                Helper.GetList<IResourceRecord>(record3));

            response.Id = 1;
            response.RecursionAvailable = true;

            byte[] content = Helper.ReadFixture("Response", "id-ra_all");

            CollectionAssert.AreEqual(content, response.ToArray());
        }
Ejemplo n.º 2
0
        public void CNameResourceRecordWithEmptyDomain()
        {
            byte[] content = Helper.ReadFixture("ResourceRecord", "empty-domain_cname");

            Domain domain = new Domain(Helper.GetArray<string>());
            ResourceRecord record = new ResourceRecord(domain, Helper.GetArray<byte>(),
                RecordType.CNAME, RecordClass.IN, new TimeSpan(0));

            CollectionAssert.AreEqual(content, record.ToArray());
        }
Ejemplo n.º 3
0
        public void BasicResourceRecordWithMultipleLabelDomain()
        {
            byte[] content = Helper.ReadFixture("ResourceRecord", "www.google.com_basic");

            Domain domain = new Domain(Helper.GetArray("www", "google", "com"));
            ResourceRecord record = new ResourceRecord(domain, Helper.GetArray<byte>(),
                RecordType.A, RecordClass.IN, new TimeSpan(0));

            CollectionAssert.AreEqual(content, record.ToArray());
        }
Ejemplo n.º 4
0
        public void DataResourceRecordWithEmptyDomain()
        {
            byte[] content = Helper.ReadFixture("ResourceRecord", "empty-domain_data");

            byte[] data = Helper.GetArray<byte>(1, 1);
            Domain domain = new Domain(Helper.GetArray<string>());
            ResourceRecord record = new ResourceRecord(domain, data,
                RecordType.A, RecordClass.IN, new TimeSpan());

            CollectionAssert.AreEqual(content, record.ToArray());
        }
Ejemplo n.º 5
0
        public void AllSetResourceRecordWithMultipleLabelDomain()
        {
            byte[] content = Helper.ReadFixture("ResourceRecord", "www.google.com_all");

            byte[] data = Helper.GetArray<byte>(1, 1);
            Domain domain = new Domain(Helper.GetArray("www", "google", "com"));
            ResourceRecord record = new ResourceRecord(domain, data,
                RecordType.CNAME, RecordClass.ANY, TimeSpan.FromSeconds(1));

            CollectionAssert.AreEqual(content, record.ToArray());
        }
Ejemplo n.º 6
0
        public void BasicQuestionResponseWithEmptyHeader()
        {
            Header header = new Header();
            header.Response = true;

            Domain domain = new Domain(Helper.GetArray<string>());
            Question question = new Question(domain, RecordType.A, RecordClass.IN);
            ResourceRecord record = new ResourceRecord(domain, Helper.GetArray<byte>(0, 0, 0, 0),
                RecordType.A, RecordClass.IN, new TimeSpan());

            Response response = new Response(header,
                Helper.GetList(question),
                Helper.GetList<IResourceRecord>(record),
                Helper.GetList<IResourceRecord>(record),
                Helper.GetList<IResourceRecord>(record));

            byte[] content = Helper.ReadFixture("Response", "empty-header_basic");

            CollectionAssert.AreEqual(content, response.ToArray());
        }
Ejemplo n.º 7
0
        public void TtlResourceRecordWithEmptyDomain()
        {
            byte[] content = Helper.ReadFixture("ResourceRecord", "empty-domain_ttl");

            Domain domain = new Domain(Helper.GetArray<string>());
            ResourceRecord record = new ResourceRecord(domain, Helper.GetArray<byte>(),
                RecordType.A, RecordClass.IN, TimeSpan.FromSeconds(1));

            CollectionAssert.AreEqual(content, record.ToArray());
        }