Beispiel #1
0
        private static void Write(string fieldName, HostName expectedValue)
        {
            if (expectedValue == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(expectedValue.ToString()) == false)
            {
                Write($"{fieldName}.ToString()", expectedValue.ToString());
            }

            if (string.IsNullOrEmpty(expectedValue.ToUnicodeString()) == false && expectedValue.IsPunyCode)
            {
                Write($"{fieldName}.ToUnicodeString()", expectedValue.ToString());
            }
        }
Beispiel #2
0
        public void TestCreateValidHostName()
        {
            var host = new HostName("flipbit.co.uk");

            Assert.AreEqual("flipbit.co.uk", host.ToString());
            Assert.AreEqual(false, host.IsPunyCode);
            Assert.AreEqual(false, host.IsTld);
            Assert.AreEqual("uk", host.Tld);
        }
Beispiel #3
0
        public void TestCreateValidHostNameWhenHasMultipleSubdomains()
        {
            var host = new HostName("www.housekenya.co.ke");

            Assert.AreEqual("www.housekenya.co.ke", host.ToString());
            Assert.AreEqual(false, host.IsPunyCode);
            Assert.AreEqual(false, host.IsTld);
            Assert.AreEqual("ke", host.Tld);
            Assert.AreEqual("www.housekenya.co.ke", host.ToUnicodeString());
        }
Beispiel #4
0
        public void TestCreateValidHostNameWhenUnicode()
        {
            var host = new HostName("nic.vermögensberater");

            Assert.AreEqual("nic.xn--vermgensberater-ctb", host.ToString());
            Assert.AreEqual(true, host.IsPunyCode);
            Assert.AreEqual(false, host.IsTld);
            Assert.AreEqual("xn--vermgensberater-ctb", host.Tld);
            Assert.AreEqual("nic.vermögensberater", host.ToUnicodeString());
        }