Esempio n. 1
0
 public void ExtractsHashtagsCorrectly(SimpleTwitterCase testCase)
 {
     Extractor testExtractor = new Extractor();
     var m = testExtractor.ExtractHashtags(testCase.TestString);
     Assert.AreEqual(testCase.ExpectedTags.Count(), m.Count, testCase.Description);
     foreach (var tag in m)
     {
         Assert.Contains(tag, testCase.ExpectedTags, tag + " Not Found");
     }
 }
Esempio n. 2
0
 public void ExtractsUrlsCorrectly(SimpleTwitterCase testCase)
 {
     Extractor testExtractor = new Extractor();
     var m = testExtractor.ExtractURLs(testCase.TestString);
     Assert.AreEqual(testCase.ExpectedTags.Count(), m.Count, testCase.Description);
 }
Esempio n. 3
0
        public SimpleTwitterCase[] GetSingleNestedTagCaseData(string testCollectionName)
        {
            var cases = new List<SimpleTwitterCase>();
            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 expectedTagNode = (YamlSequenceNode)test.Children[new YamlScalarNode("expected")];
                    var tags = expectedTagNode.Children.Select(t => t.ToString()).ToArray();
                    var c = new SimpleTwitterCase()
                        {
                            Description = test.Children[new YamlScalarNode("description")].ToString(),
                            TestString = test.Children[new YamlScalarNode("text")].ToString(),
                            ExpectedTags = tags
                        };
                    cases.Add(c);
                }
            }
            return cases.ToArray();
        }
Esempio n. 4
0
        public void ExtractsRepliesCorrectly(SimpleTwitterCase testCase)
        {
            Extractor testExtractor = new Extractor();
            var m = testExtractor.ExtractReplyScreenname(testCase.TestString);

            if (m == null)
            {
                Assert.IsEmpty(testCase.ExpectedTags.First(), testCase.Description);
            }
            else
            {
                Assert.AreEqual(testCase.ExpectedTags.First(), m, testCase.Description);
            }
        }