Esempio n. 1
0
        public async void ShouldNotResolveLocalhostOnMonoAsync(bool ipv6Preferred)
        {
            var resolverMock = new Mock <IHostResolver>(MockBehavior.Strict);
            var resolver     = new DefaultHostResolver(resolverMock.Object, ipv6Preferred);

            await resolver.ResolveAsync("localhost");
        }
Esempio n. 2
0
        public async void ShouldParseIPv6LoopbackAsync(bool ipv6Preferred)
        {
            var resolver    = new DefaultHostResolver(ipv6Preferred);
            var ipAddresses = await resolver.ResolveAsync("[::1]");

            ipAddresses.Should().HaveCount(1).And.Contain(IPAddress.IPv6Loopback);
        }
Esempio n. 3
0
        public async void ShouldParseLoopbackWhenIPv6PreferredAsync()
        {
            var resolver    = new DefaultHostResolver(true);
            var ipAddresses = await resolver.ResolveAsync("127.0.0.1");

            ipAddresses.Should().HaveCount(2).And.ContainInOrder(IPAddress.IPv6Loopback, IPAddress.Loopback);
        }
Esempio n. 4
0
        public async void ShouldParseLoopbackAsync()
        {
            var resolver    = new DefaultHostResolver(false);
            var ipAddresses = await resolver.ResolveAsync("127.0.0.1");

            ipAddresses.Should().HaveCount(1).And.Contain(IPAddress.Loopback);
        }
Esempio n. 5
0
        public async void ShouldResolveAsync(bool ipv6Preferred)
        {
            var resolverMock = new Mock <IHostResolver>();
            var resolver     = new DefaultHostResolver(resolverMock.Object, ipv6Preferred);

            await resolver.ResolveAsync("some_host");

            resolverMock.Verify(r => r.ResolveAsync("some_host"));
        }
Esempio n. 6
0
        public async void ShouldParseLocalhostAsync(bool ipv6Preferred)
        {
            var resolver    = new DefaultHostResolver(ipv6Preferred);
            var ipAddresses = await resolver.ResolveAsync("LocALhOsT");

#if NET452
            ipAddresses.Should().Contain(IPAddress.IPv6Loopback);
            ipAddresses.Should().Contain(IPAddress.Loopback);
            ipAddresses.Should().Contain(IPAddress.Parse("[::1]"));
#endif
            ipAddresses.Should().Contain(IPAddress.Parse("127.0.0.1"));
        }
Esempio n. 7
0
        public async void ShouldOrderIPv6FirstWhenIPv6PreferredAsync()
        {
            var resolverMock = new Mock <IHostResolver>();

            resolverMock.Setup(x => x.ResolveAsync(It.IsAny <string>())).Returns(Task.FromResult(new[]
                                                                                                 { IPAddress.Parse("10.0.0.1"), IPAddress.Parse("[::1]"), IPAddress.Parse("192.168.0.11") }));

            var resolver    = new DefaultHostResolver(resolverMock.Object, true);
            var ipAddresses = await resolver.ResolveAsync("some_host");

            ipAddresses.Should().HaveCount(3).And.ContainInOrder(IPAddress.Parse("[::1]"), IPAddress.Parse("10.0.0.1"),
                                                                 IPAddress.Parse("192.168.0.11"));
        }