コード例 #1
0
        public void GetFullHostName_Combines_HostNameAndPopulatedDomain_Correctly()
        {
            var dnsStatic = new DnsStatic(_mockNetworkData);
            var hostname  = dnsStatic.GetHostName();

            Mock.Arrange(() => _mockNetworkData.GetDomainName(Arg.IsAny <INetworkInterfaceData>())).Returns(DomainName);
            var expectedHostname = $"{hostname}.{DomainName}";

            // ACT
            var actualHostname = dnsStatic.GetFullHostName();

            Assert.That(actualHostname, Is.EqualTo(expectedHostname));
        }
コード例 #2
0
        public string GetFullHostName()
        {
            var hostName = GetHostName();
            var activeNetworkInterface = GetActiveNetworkInterface();
            var domainName             = _networkData.GetDomainName(activeNetworkInterface);

            if (!string.IsNullOrEmpty(domainName) && !hostName.EndsWith(domainName))
            {
                hostName += $".{domainName}";
            }

            return(hostName);
        }