I'm working on a twitter text c# library and twitter has added a double word unicode character test to their conformance tests.
https://github.com/twitter/twitter-text-conformance/blob/master/validate.yml
Here's an nUnit test method to run against the above file.
[Test]
public void TestDoubleWordUnicodeYamlRetrieval()
{
var yamlFile = "validate.yml";
Assert.IsTrue(File.Exists(conformanceDir + yamlFile), "Yaml file " + conformanceDir + yamlFile + " does not exist.");
var stream = new StreamReader(Path.Combine(conformanceDir, yamlFile));
var yaml = new YamlStream();
yaml.Load(stream);
var root = yaml.Documents[0].RootNode as YamlMappingNode;
var testNode = new YamlScalarNode("tests");
Assert.IsTrue(root.Children.ContainsKey(testNode), "Document is missing test node.");
var tests = root.Children[testNode] as YamlMappingNode;
Assert.IsNotNull(tests, "Test node is not YamlMappingNode");
var typeNode = new YamlScalarNode("lengths");
Assert.IsTrue(tests.Children.ContainsKey(typeNode), "Test type lengths not found in tests.");
var typeTests = tests.Children[typeNode] as YamlSequenceNode;
Assert.IsNotNull(typeTests, "lengths tests are not YamlSequenceNode");
var list = new List<dynamic>();
var count = 0;
foreach (YamlMappingNode item in typeTests)
{
var text = ConvertNode<string>(item.Children.Single(x => x.Key.ToString() == "text").Value) as string;
var description = ConvertNode<string>(item.Children.Single(x => x.Key.ToString() == "description").Value) as string;
Assert.DoesNotThrow(() => {text.Normalize(NormalizationForm.FormC);}, String.Format("Yaml couldn't parse a double word unicode string at test {0} - {1}.", count, description));
count++;
}
}
This is the error produced: Vocus.TwitterText.Tests.ConformanceTest.TestDoubleWordUnicodeYamlRetrieval: Yaml couldn't parse a double word unicode string at test 5 - Count unicode chars outside the basic multilingual plane (double word). Unexpected exception: System.ArgumentException