System.Globalization.Tests.UseStd3AsciiRules.UseStd3AsciiRules_ChangesGetAsciiBehavior C# (CSharp) Method

UseStd3AsciiRules_ChangesGetAsciiBehavior() private method

private UseStd3AsciiRules_ChangesGetAsciiBehavior ( string unicode, bool containsInvalidHyphen ) : void
unicode string
containsInvalidHyphen bool
return void
        public void UseStd3AsciiRules_ChangesGetAsciiBehavior(string unicode, bool containsInvalidHyphen)
        {
            var idnStd3False = new IdnMapping { UseStd3AsciiRules = false };
            var idnStd3True = new IdnMapping { UseStd3AsciiRules = true };

            if (containsInvalidHyphen && !s_isWindows)
            {
                // ICU always fails on leading/trailing hyphens regardless of the Std3 rules option.
                Assert.Throws<ArgumentException>("unicode", () => idnStd3False.GetAscii(unicode));
            }
            else
            {
                Assert.Equal(unicode, idnStd3False.GetAscii(unicode));
            }

            ArgumentException ae = Assert.Throws<ArgumentException>(() => idnStd3True.GetAscii(unicode));
            // sometimes the desktop returns "Unicode" instead of "unicode" for the parameter name.
            Assert.Equal("unicode", ae.ParamName, ignoreCase: true);
        }