Example #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void testGetHostAddressUnknown()
        internal virtual void TestGetHostAddressUnknown()
        {
            // Given
            string unknownHost = "unknownHost";

            assertThrows(typeof(UnknownHostException), () => InetAddress.getByName(unknownHost));

            // should return hostname when it is unknown
            assertThat(HostnamePort.GetHostAddress(unknownHost, "default"), equalTo(unknownHost));
        }
Example #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void testGetHostAddress() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void TestGetHostAddress()
        {
            // Given
            string hostName = InetAddress.LocalHost.HostName;

            // When & Then

            // should return default, when host is null
            assertThat(HostnamePort.GetHostAddress(null, "default"), equalTo("default"));

            // should return host ip address when host is known
            assertThat(HostnamePort.GetHostAddress(hostName, "default"), equalTo(hostName));
        }