Exemplo n.º 1
0
 public void Should_Return_Non_Existent_Domain_Because_No_Entry_Matches()
 {
     var dnsResolver = Mock.Of<IDnsResolver>(mock => mock.Resolve(It.IsAny<DnsRequest>()) == new DnsResolutionResult());
     IDnsQueryHandler queryHandler = new DnsQueryHandler(dnsResolver);
     var message = new DnsMessage() {Questions = new List<DnsQuestion>() {new DnsQuestion("test", RecordType.A, RecordClass.Any)}};
     DnsMessageBase processedMessage = queryHandler.HandleQuery(message, null, ProtocolType.IP);
     processedMessage.ReturnCode.Should().Be(ReturnCode.NxDomain);
 }
Exemplo n.º 2
0
 public void Should_Return_DNS_Error_Because_No_Entry_Was_Requested()
 {
     var dnsResolver = Mock.Of<IDnsResolver>();
     IDnsQueryHandler queryHandler = new DnsQueryHandler(dnsResolver);
     var message = new DnsMessage();
     DnsMessageBase processedMessage = queryHandler.HandleQuery(message, null, ProtocolType.IP);
     processedMessage.ReturnCode.Should().Be(ReturnCode.ServerFailure);
 }
Exemplo n.º 3
0
 public void Should_Return_No_Error_Because_Entry_Matches()
 {
     var dnsResolver = Mock.Of<IDnsResolver>(mock => mock.Resolve(It.IsAny<DnsRequest>()) == new DnsResolutionResult()
     {
         DnsEntry = new DnsEntry() { Name = "test", IpV4 = "0.0.0.0"}
     });
     IDnsQueryHandler queryHandler = new DnsQueryHandler(dnsResolver);
     var message = new DnsMessage() { Questions = new List<DnsQuestion>() { new DnsQuestion("test", RecordType.A, RecordClass.Any) } };
     queryHandler.HandleQuery(message, null, ProtocolType.IP);
     message.ReturnCode.Should().Be(ReturnCode.NoError);
 }