Пример #1
0
        public async Task Resolve_ShouldResolve_HostName()
        {
            // Arrange
            const string host  = "some.host.com";
            const string ip    = "134.27.41.216";
            var          token = new CancellationToken();

            _lookupClient.QueryAsync(host, QueryType.A, cancellationToken: token)
            .Returns(new DnsQueryResponse
            {
                HasError = false,
                Answers  = new DnsResourceRecord[]
                {
                    new ARecord(
                        new ResourceRecordInfo(host, ResourceRecordType.A, QueryClass.IN, 5, 5),
                        IPAddress.Parse(ip))
                }
            });
            var client = new FixedDnsClient(_lookupClient);
            // Act
            var result = await client.Resolve(ip, token);

            // Assert
            result.Should().Be(ip);
        }
Пример #2
0
        public async Task Resolve_ShouldResolve_IPAddress()
        {
            // Arrange
            const string ip     = "134.27.41.216";
            var          client = new FixedDnsClient(_lookupClient);
            // Act
            var result = await client.Resolve(ip, CancellationToken.None);

            // Assert
            result.Should().Be(ip);
        }