1

私は twitter テキスト c# ライブラリに取り組んでおり、twitter は適合テストにダブルワード Unicode 文字テストを追加しました。

https://github.com/twitter/twitter-text-conformance/blob/master/validate.yml

上記のファイルに対して実行する nUnit テスト メソッドを次に示します。

    [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++;
        }
    }

次のエラーが生成されます。予期しない例外: System.ArgumentException

4

1 に答える 1