예제 #1
0
        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]));
        }
예제 #2
0
        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]));
        }
예제 #3
0
        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]));
        }
예제 #4
0
        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)));
        }
예제 #5
0
        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)));
        }
예제 #6
0
        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)));
        }