public void MatchesUrl() { Match m = new Match(MatchTypes.URL, "test"); var item = new RilListItem { Title = "test1", Url = "test.com" }; Assert.IsTrue(m.MatchesItem(item)); }
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); }
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)); }
public void AddNextTag() { var pt = kernel.Get<PocketTagger>(); var item = new RilListItem { Url = "http://www.google.be?2", Tags = "test"} ; string newTag = "newTag"; pt.AddTag(item, newTag); Assert.IsTrue(item.Tags.Split(',').Contains(newTag)); }
public void AddExistingTagDoesNotDuplicate() { var pt = kernel.Get<PocketTagger>(); var item = new RilListItem { Url = "http://www.google.be?2", Tags = "test" }; string newTag = "test"; pt.AddTag(item, newTag); Assert.AreEqual(1,item.Tags.Split(',').Count(t=>t == newTag)); }
public void AddDuplicateTagDoesNothing() { var pt = kernel.Get<PocketTagger>(); var item = new RilListItem { Url = "http://www.google.be?2", Tags = "test" }; string newTag = "test"; bool tagModified = pt.AddTag(item, newTag); Assert.IsFalse(tagModified); Assert.AreEqual(1, item.Tags.Split(',').Count()); }
internal bool MatchesItem(RilListItem item) { switch (MatchType) { case MatchTypes.URL: return MatchesUrl(item.Url); case MatchTypes.Title: return MatchesTitle(item.Title); default: throw new NotSupportedException(String.Format("Match type {0} not supported.", MatchType)); } }
internal virtual bool HasMatch(RilListItem item) { return Matches.Any(m => m.MatchesItem(item)); }
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)); }
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); }