public void TestValidation() { DnsRequest request = DnsRequest.CreateA("foo.com"); Assert.Null(Record.Exception(() => request.Validate())); request.Header.IsRequest = false; Assert.Throws <DnsProtocolException>(() => request.Validate()); }
protected void Validate(DnsRequest request) { request.Validate(); if (request.Header.QuestionCount < 1) { throw new DnsProtocolException(DnsProtocolError.InvalidQuestionCount); } if (request.Header.QuestionCount > this.Settings.MaxQuestionCount) { throw new DnsServerException(DnsStandard.ResponseCode.Refused); } }