ToArray() public method

public ToArray ( ) : byte[]
return byte[]
Beispiel #1
0
        public void EmptyHeader()
        {
            Header header = new Header();
            byte[] content = Helper.ReadFixture("Header", "empty");

            CollectionAssert.AreEqual(content, header.ToArray());
        }
Beispiel #2
0
        public void HeaderWithAuthorityRecordCount()
        {
            Header header = new Header();
            header.AuthorityRecordCount = 1;
            byte[] content = Helper.ReadFixture("Header", "nscount");

            CollectionAssert.AreEqual(content, header.ToArray());
        }
Beispiel #3
0
        public void HeaderWithAuthorativeAnswerFlag()
        {
            Header header = new Header();
            header.AuthorativeServer = true;
            byte[] content = Helper.ReadFixture("Header", "aa");

            CollectionAssert.AreEqual(content, header.ToArray());
        }
Beispiel #4
0
        public byte[] ToArray()
        {
            UpdateHeader();
            ByteStream result = new ByteStream(Size);

            result
            .Append(header.ToArray())
            .Append(questions.Select(q => q.ToArray()));

            return(result.ToArray());
        }
Beispiel #5
0
        public byte[] ToArray()
        {
            UpdateHeader();
            ByteStream result = new ByteStream(Size);

            result
            .Append(header.ToArray())
            .Append(questions.Select(q => q.ToArray()))
            .Append(answers.Select(a => a.ToArray()))
            .Append(authority.Select(a => a.ToArray()))
            .Append(additional.Select(a => a.ToArray()));

            return(result.ToArray());
        }
Beispiel #6
0
        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());
        }
Beispiel #7
0
        public void HeaderWithOperationCode()
        {
            Header header = new Header();
            header.OperationCode = OperationCode.Status;
            byte[] content = Helper.ReadFixture("Header", "opcode");

            CollectionAssert.AreEqual(content, header.ToArray());
        }
Beispiel #8
0
        public void HeaderWithId()
        {
            Header header = new Header();
            header.Id = 1;
            byte[] content = Helper.ReadFixture("Header", "id");

            CollectionAssert.AreEqual(content, header.ToArray());
        }
Beispiel #9
0
        public void HeaderWithTruncatedFlag()
        {
            Header header = new Header();
            header.Truncated = true;
            byte[] content = Helper.ReadFixture("Header", "tc");

            CollectionAssert.AreEqual(content, header.ToArray());
        }
Beispiel #10
0
        public void HeaderWithResponseCode()
        {
            Header header = new Header();
            header.ResponseCode = ResponseCode.ServerFailure;
            byte[] content = Helper.ReadFixture("Header", "rcode");

            CollectionAssert.AreEqual(content, header.ToArray());
        }
Beispiel #11
0
        public void HeaderWithRecusionDesiredFlag()
        {
            Header header = new Header();
            header.RecursionDesired = true;
            byte[] content = Helper.ReadFixture("Header", "rd");

            CollectionAssert.AreEqual(content, header.ToArray());
        }
Beispiel #12
0
        public void HeaderWithQuestionCount()
        {
            Header header = new Header();
            header.QuestionCount = 1;
            byte[] content = Helper.ReadFixture("Header", "qdcount");

            CollectionAssert.AreEqual(content, header.ToArray());
        }
Beispiel #13
0
        public void HeaderWithQueryResponseFlag()
        {
            Header header = new Header();
            header.Response = true;
            byte[] content = Helper.ReadFixture("Header", "qr");

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