Esempio n. 1
0
        public void ShouldParseLoopback()
        {
            var resolver    = new DefaultHostResolver(false);
            var ipAddresses = resolver.Resolve("127.0.0.1");

            ipAddresses.Should().HaveCount(1).And.Contain(IPAddress.Loopback);
        }
Esempio n. 2
0
        public void ShouldParseLoopbackWhenIPv6Preferred()
        {
            var resolver    = new DefaultHostResolver(true);
            var ipAddresses = resolver.Resolve("127.0.0.1");

            ipAddresses.Should().HaveCount(2).And.ContainInOrder(IPAddress.IPv6Loopback, IPAddress.Loopback);
        }
Esempio n. 3
0
        public void ShouldNotResolveLocalhostOnMono(bool ipv6Preferred)
        {
            var resolverMock = new Mock <IHostResolver>(MockBehavior.Strict);
            var resolver     = new DefaultHostResolver(resolverMock.Object, ipv6Preferred);

            resolver.Resolve("localhost");
        }
Esempio n. 4
0
        public void ShouldParseIPv6Loopback(bool ipv6Preferred)
        {
            var resolver    = new DefaultHostResolver(ipv6Preferred);
            var ipAddresses = resolver.Resolve("[::1]");

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

            resolver.Resolve("some_host");

            resolverMock.Verify(r => r.Resolve("some_host"));
        }
Esempio n. 6
0
        public void ShouldParseLocalhost(bool ipv6Preferred)
        {
            var resolver    = new DefaultHostResolver(ipv6Preferred);
            var ipAddresses = resolver.Resolve("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 void ShouldOrderIPv6FirstWhenIPv6Preferred()
        {
            var resolverMock = new Mock <IHostResolver>();

            resolverMock.Setup(x => x.Resolve(It.IsAny <string>())).Returns(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 = resolver.Resolve("some_host");

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