예제 #1
0
 public void PassesTwitterIndexesForHashTags(IndexedTwitterTest testCase)
 {
     Extractor testExtractor = new Extractor();
     var m = testExtractor.ExtractHashtags(testCase.TestString);
     foreach (var expect in testCase.Expectations)
     {
         Assert.Fail("NotImplemented");
     }
 }
예제 #2
0
        public IndexedTwitterTest[] GetIndexedTagCaseData(string testCollectionName, string keyName)
        {
            var cases = new List<IndexedTwitterTest>();
            using (TextReader reader = File.OpenText(@"./extract.yml"))
            {
                var ymlDoc = new YamlStream();
                ymlDoc.Load(reader);

                var root = (YamlMappingNode)ymlDoc.Documents[0].RootNode;

                var tests = (YamlMappingNode)root.Children[new YamlScalarNode("tests")];
                foreach (YamlMappingNode test in (YamlSequenceNode)tests.Children[new YamlScalarNode(testCollectionName)])
                {
                    var c = new IndexedTwitterTest()
                    {
                        Description = test.Children[new YamlScalarNode("description")].ToString(),
                        TestString = test.Children[new YamlScalarNode("text")].ToString(),
                    };
                    var expectations = (YamlSequenceNode)test.Children[new YamlScalarNode("expected")];

                    foreach (YamlMappingNode expectation in expectations.Children)
                    {
                        var tag = expectation.Children[new YamlScalarNode(keyName)].ToString();
                        var indicesNode = (YamlSequenceNode)expectation.Children[new YamlScalarNode("indices")];
                        var indices = indicesNode.Children.Select(t => int.Parse(t.ToString())).ToArray();

                        var e = new IndexedTwitterTest.Expectation()
                            {
                                HashTag = tag,
                                Indices = indices
                            };
                        c.Expectations.Add(e);
                    }

                    cases.Add(c);
                }
            }
            return cases.ToArray();
        }