public void EmptyHeader() { Header header = new Header(); byte[] content = Helper.ReadFixture("Header", "empty"); CollectionAssert.AreEqual(content, header.ToArray()); }
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()); }
public void HeaderWithAuthorativeAnswerFlag() { Header header = new Header(); header.AuthorativeServer = true; byte[] content = Helper.ReadFixture("Header", "aa"); CollectionAssert.AreEqual(content, header.ToArray()); }
public void HeaderWithAuthorityRecordCount() { Header header = new Header(); header.AuthorityRecordCount = 1; byte[] content = Helper.ReadFixture("Header", "nscount"); CollectionAssert.AreEqual(content, header.ToArray()); }
public Request() { this.questions = new List<Question>(); this.header = new Header(); this.header.OperationCode = OperationCode.Query; this.header.Response = false; this.header.Id = RANDOM.Next(UInt16.MaxValue); }
public Response(Header header, IList<Question> questions, IList<IResourceRecord> answers, IList<IResourceRecord> authority, IList<IResourceRecord> additional) { this.header = header; this.questions = questions; this.answers = answers; this.authority = authority; this.additional = additional; }
public Response() { this.header = new Header(); this.questions = new List<Question>(); this.answers = new List<IResourceRecord>(); this.authority = new List<IResourceRecord>(); this.additional = new List<IResourceRecord>(); this.header.Response = true; this.header.Id = RANDOM.Next(UInt16.MaxValue); }
public Request(IRequest request) { this.header = new Header(); this.questions = new List<Question>(request.Questions); this.header.Response = false; Id = request.Id; OperationCode = request.OperationCode; RecursionDesired = request.RecursionDesired; }
public Response(IResponse response) { this.header = new Header(); this.questions = new List<Question>(response.Questions); this.answers = new List<IResourceRecord>(response.AnswerRecords); this.authority = new List<IResourceRecord>(response.AuthorityRecords); this.additional = new List<IResourceRecord>(response.AdditionalRecords); this.header.Response = true; Id = response.Id; RecursionAvailable = response.RecursionAvailable; AuthorativeServer = response.AuthorativeServer; OperationCode = response.OperationCode; ResponseCode = response.ResponseCode; }
public void HeaderWithAllSet() { Header header = new Header(); header.Id = 1; header.Response = true; header.OperationCode = OperationCode.Status; header.AuthorativeServer = true; header.Truncated = true; header.RecursionDesired = true; header.RecursionAvailable = true; header.ResponseCode = ResponseCode.ServerFailure; header.QuestionCount = 1; header.AnswerRecordCount = 1; header.AuthorityRecordCount = 1; header.AdditionalRecordCount = 1; byte[] content = Helper.ReadFixture("Header", "all"); CollectionAssert.AreEqual(content, header.ToArray()); }
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()); }
public void HeaderWithTruncatedFlag() { Header header = new Header(); header.Truncated = true; byte[] content = Helper.ReadFixture("Header", "tc"); CollectionAssert.AreEqual(content, header.ToArray()); }
public void HeaderWithResponseCode() { Header header = new Header(); header.ResponseCode = ResponseCode.ServerFailure; byte[] content = Helper.ReadFixture("Header", "rcode"); CollectionAssert.AreEqual(content, header.ToArray()); }
public void HeaderWithRecusionDesiredFlag() { Header header = new Header(); header.RecursionDesired = true; byte[] content = Helper.ReadFixture("Header", "rd"); CollectionAssert.AreEqual(content, header.ToArray()); }
public void HeaderWithId() { Header header = new Header(); header.Id = 1; byte[] content = Helper.ReadFixture("Header", "id"); CollectionAssert.AreEqual(content, header.ToArray()); }
public void HeaderWithQueryResponseFlag() { Header header = new Header(); header.Response = true; byte[] content = Helper.ReadFixture("Header", "qr"); CollectionAssert.AreEqual(content, header.ToArray()); }
public void HeaderWithQuestionCount() { Header header = new Header(); header.QuestionCount = 1; byte[] content = Helper.ReadFixture("Header", "qdcount"); CollectionAssert.AreEqual(content, header.ToArray()); }
public void HeaderWithOperationCode() { Header header = new Header(); header.OperationCode = OperationCode.Status; byte[] content = Helper.ReadFixture("Header", "opcode"); CollectionAssert.AreEqual(content, header.ToArray()); }
public Request(Header header, IList<Question> questions) { this.header = header; this.questions = questions; }