Beispiel #1
0
        public void IsNormalized_Invalid()
        {
            Assert.Throws <ArgumentException>(() => "\uFB01".IsNormalized((NormalizationForm)10));

            Assert.Throws <ArgumentException>("strInput", () => "\uFFFE".IsNormalized());       // Invalid codepoint
            Assert.Throws <ArgumentException>("strInput", () => "\uD800\uD800".IsNormalized()); // Invalid surrogate pair

            Assert.Throws <ArgumentNullException>("strInput", () => StringNormalizationExtensions.IsNormalized(null));
        }
        public void IsNormalized_Invalid()
        {
            Assert.Throws <ArgumentException>(() => "\uFB01".IsNormalized((NormalizationForm)10));

            Assert.Throws <ArgumentException>("strInput", () => "\uFFFE".IsNormalized());       // Invalid codepoint
            Assert.Throws <ArgumentException>("strInput", () => "\uD800\uD800".IsNormalized()); // Invalid surrogate pair

            Assert.Throws <ArgumentNullException>("strInput", () => StringNormalizationExtensions.IsNormalized(null));

            Exception exception = Record.Exception(() => ((string)null).IsNormalized());

            // On desktop IsNormalized is not extension method, trying to do ((string)null).IsNormalized()
            // will get NullReferenceException, in .Net Core we use extension method which will throw
            // ArgumentNullException
            Assert.True((exception is ArgumentNullException) || (exception is NullReferenceException));
        }
        public void ExceptionsTest()
        {
            string fi = "\uFB01";

            //  "Expected to throw with invalid Normalization"
            Assert.Throws <ArgumentException>(() => fi.IsNormalized((NormalizationForm)10));
            // "Expected to throw with invalid Normalization"
            Assert.Throws <ArgumentException>(() => fi.Normalize((NormalizationForm)7));

            string invalidCodepoint = "\uFFFE";
            string invalidSurrogate = "\uD800\uD800";

            // "Expected to throw with invalid codepoint"
            Assert.Throws <ArgumentException>(() => invalidCodepoint.Normalize());
            Assert.Throws <ArgumentException>(() => invalidCodepoint.IsNormalized());
            // "Expected to throw with invalid surrogate pair"
            Assert.Throws <ArgumentException>(() => invalidSurrogate.Normalize());
            Assert.Throws <ArgumentException>(() => invalidSurrogate.IsNormalized());

            //  "Expected ArgumentNullException when passing null string"
            Assert.Throws <ArgumentNullException>(() => StringNormalizationExtensions.Normalize(null));
            Assert.Throws <ArgumentNullException>(() => StringNormalizationExtensions.IsNormalized(null));
        }
 public void IsNormalized_Null()
 {
     AssertExtensions.Throws <ArgumentNullException>("strInput", () => StringNormalizationExtensions.IsNormalized(null));
 }