Пример #1
0
 public void SingleTitleParsesTitle()
 {
     string line = "title-test:title=title1";
     TagRulesLoader trl = new TagRulesLoader();
     TagRule tagRule = trl.LoadInstruction(line);
     var item = new RilListItem { Title = "title1", Url = "test1.com" };
     Assert.AreEqual(MatchTypes.Title, tagRule.Matches.First().MatchType);
 }
Пример #2
0
        public void SingleLineParsesTag()
        {
            string line = "android-apps:url=test1.com";
            TagRulesLoader trl = new TagRulesLoader();
            TagRule tagRule = trl.LoadInstruction(line);

            Assert.AreEqual("android-apps", tagRule.Tag);
        }
Пример #3
0
 public void SingleTitleMatchTitle()
 {
     string line = "title-test:title=title1";
     TagRulesLoader trl = new TagRulesLoader();
     TagRule tagRule = trl.LoadInstruction(line);
     var item = new RilListItem { Title = "title1", Url = "test1.com" };
     Assert.IsTrue(tagRule.HasMatch(item));
 }
Пример #4
0
        public void MultipleLinesParsesAll()
        {
            string[] lines = new string[] { "test-tag1:url=test1.com", "test-tag2:url=test2.com" };
            TagRulesLoader trl = new TagRulesLoader();
            IEnumerable<TagRule> tagRule = trl.LoadInstruction(lines);

            Assert.AreEqual(lines.Length, tagRule.Count());
        }
Пример #5
0
        public void LoadFile()
        {
            TagRulesLoader trl = new TagRulesLoader();
            string filename = "testrules.tgr";
            IEnumerable<TagRule> tagRules = trl.LoadInstructionFile(filename);

            int expectedTagRules = File.ReadAllLines(filename).Where(line=>!String.IsNullOrWhiteSpace(line)).Count();
            Assert.AreEqual(expectedTagRules, tagRules.Count());
        }
Пример #6
0
        public void DuplicateTagsCollapsesToOneTagRuleTwoMatches()
        {
            string[] lines = new string[] { "test-tag:url=test1.com", "test-tag:url=test2.com" };
            TagRulesLoader trl = new TagRulesLoader();
            IEnumerable<TagRule> tagRule = trl.LoadInstruction(lines);

            Assert.AreEqual(1, tagRule.Count());
            Assert.AreEqual(2, tagRule.First().Matches.Count);
        }
Пример #7
0
 public void SingleUrlMatchesUrl()
 {
     string line = "android-apps:url=test1";
     TagRulesLoader trl = new TagRulesLoader();
     TagRule tagRule = trl.LoadInstruction(line);
     var item = new RilListItem { Title = "test1", Url = "test1.com" };
     Assert.IsTrue(tagRule.HasMatch(item));
 }
Пример #8
0
 public void SingleUnsupportedMatchTypeThrowsException()
 {
     string line = "title-test:notvalid=title1";
     TagRulesLoader trl = new TagRulesLoader();
     TagRule tagRule = trl.LoadInstruction(line);
 }
Пример #9
0
 public void SingleLineInvalidFormatThrowsException()
 {
     TagRulesLoader trl = new TagRulesLoader();
     TagRule tagRule = trl.LoadInstruction("thiswillfail");
 }
Пример #10
0
 public void SingleUrlParsesUrl()
 {
     string line = "android-apps:url=test1";
     TagRulesLoader trl = new TagRulesLoader();
     TagRule tagRule = trl.LoadInstruction(line);
     var item = new RilListItem { Title = "test1", Url = "test1.com" };
     Assert.AreEqual(MatchTypes.URL, tagRule.Matches.First().MatchType);
 }