public void EnumerationShouldHaveExpectedResults(int[] expectedCharacters, XUnitSerializableString text)
        {
            var enumerable = ((string)text).AsPermissiveCodePointEnumerable();

            // Test C# foreach enumeration
            {
                int i = 0;
                foreach (int codePoint in enumerable)
                {
                    Assert.Equal(expectedCharacters[i++], codePoint);
                }
                Assert.Equal(expectedCharacters.Length, i);
            }

            // Test generic enumerable
            Assert.Equal(expectedCharacters, from codePoint in enumerable select codePoint);

            // Test legacy enumeration
            {
                // We could use Enumerable.Cast<>, but we can't guarantee that the LINQ implementation we use wouldn't be smart and cast IEnumerable back to IEnumerable<int>
                var legacyEnumerator = ((IEnumerable)enumerable).GetEnumerator();

                int index = 0;

                while (legacyEnumerator.MoveNext())
                {
                    Assert.True(index < expectedCharacters.Length);
                    Assert.Equal(expectedCharacters[index++], Assert.IsType <int>(legacyEnumerator.Current));
                }

                Assert.Equal(expectedCharacters.Length, index);
            }
        }
 public void EnumerationOfInvalidUtf16StringsShouldThrowArgumentException(XUnitSerializableString text)
 => Assert.Throws <ArgumentException>(() => { foreach (int codePoint in ((string)text).AsCodePointEnumerable())
                                              {
                                              }
                                      });