public void FilterShouldReturnMatchingModels() { var filters = new[] { "test1", }; var tagged = new[] { new Tagged { Tags = { "test1" } }, new Tagged { Tags = { "test1", "test2" } }, new Tagged { Tags = { "test2" } }, }; var tagManager = new TagManager(); tagManager.AddFrom(tagged); var results = tagManager.Filter(tagged, filters); Assert.True(results.Count == 2); Assert.True(results.Contains(tagged[0])); Assert.True(results.Contains(tagged[1])); }
public void FilterShouldAllowStartingOnNotSigns() { var filters = new[] { "-test*", "-dog", "- cat" }; var tagged = new[] { new Tagged { Tags = { "test1" } }, new Tagged { Tags = { "test1", "test2" } }, new Tagged { Tags = { "dog" } }, new Tagged { Tags = { "cat" } }, new Tagged { Tags = { "tortoise" } }, }; var tagManager = new TagManager(); tagManager.AddFrom(tagged); var results = tagManager.Filter(tagged, filters); Assert.True(results.Count == 1); Assert.True(results.Contains(tagged[4])); }
public void FilterShouldAllowEndingOnWildcards() { var filters = new[] { "test*" }; var tagged = new[] { new Tagged { Tags = { "test1" } }, new Tagged { Tags = { "test2" } }, new Tagged { Tags = { "test1", "test2" } }, new Tagged { Tags = { "tortoise" } }, }; var tagManager = new TagManager(); tagManager.AddFrom(tagged); var results = tagManager.Filter(tagged, filters); Assert.True(results.Count == 3); Assert.False(results.Contains(tagged[3])); }
public void ShouldNotRecommendPreviouslySearchedTags() { var search = "test"; var previous = new[] { "test1" }; var expected = new[] { "test2" }; var tagged = new[] { new Tagged { Tags = { "test1", "test2" } } }; var tagManager = new TagManager(); tagManager.AddFrom(tagged); var results = tagManager.GetRecommendations(tagged, previous, search, Search); Assert.IsTrue(expected.SequenceEqual(results.Select(r => r.SearchTag))); }
public void RecommendationsForTaggingShouldIncludeUnmatched() { var search = "test"; var previous = new[] { "test1" }; var expected = new[] { "test2" }; var tagged = new[] { new Tagged { Tags = { "test1" } } }; var tagManager = new TagManager(); tagManager.AddFrom(tagged); tagManager.Add("test2"); var results = tagManager.GetRecommendations(tagged, previous, search, Tagging); Assert.IsTrue(expected.SequenceEqual(results.Select(r => r.SearchTag))); }
public void ShouldOrderRecommendationsBasedOnOccurence() { var search = "test"; var previous = new string[0]; var expected = new[] { "test2", "test1" }; var tagged = new[] { new Tagged { Tags = { "test1", "test2" } }, new Tagged { Tags = { "test2" } } }; var tagManager = new TagManager(); tagManager.AddFrom(tagged); var results = tagManager.GetRecommendations(tagged, previous, search, Search); Assert.IsTrue(expected.SequenceEqual(results.Select(r => r.SearchTag))); }