Esempio n. 1
0
        public async Task Aggregate_Fuzzy_BuildCloud()
        {
            // arrange
            var aggregator  = new TagCloudAggregator();
            var instruction = new TagCloudInstruction(null, TagCloudClusterMode.Fuzzy);

            var answers = new Dictionary <string, TagCloudAnswer>
            {
                { "1", new TagCloudAnswer(new[] { "visual Basic", "java", "goo" }) },
                { "2", new TagCloudAnswer(new[] { "Visual Basic", "go" }) },
                { "3", new TagCloudAnswer(new[] { "Visual Basic", "go" }) },
                { "4", new TagCloudAnswer(new[] { "visualbasic" }) },
            };

            // act
            var result = (TagCloudPollResults)await aggregator.Aggregate(instruction, answers);

            // assert
            AssertCluster(new Dictionary <string, IReadOnlyList <string> >
            {
                {
                    "Visual Basic", new[] { "1", "2", "3", "4" }
                },
                {
                    "java", new[] { "1" }
                },
                {
                    "go", new[] { "1", "2", "3" }
                },
            }, result.Tags);
        }
Esempio n. 2
0
        public async Task Aggregate_CaseInsensitive_BuildCloud()
        {
            // arrange
            var aggregator  = new TagCloudAggregator();
            var instruction = new TagCloudInstruction(null, TagCloudClusterMode.CaseInsensitive);

            var answers = new Dictionary <string, TagCloudAnswer>
            {
                { "1", new TagCloudAnswer(new[] { "C#", "Visual Basic", "java" }) },
                { "2", new TagCloudAnswer(new[] { "C#", "Go", "Java" }) },
                { "3", new TagCloudAnswer(new[] { "Java", "Go", "C", "javaa" }) },
            };

            // act
            var result = (TagCloudPollResults)await aggregator.Aggregate(instruction, answers);

            // assert
            AssertCluster(new Dictionary <string, IReadOnlyList <string> >
            {
                {
                    "C#", new[] { "1", "2" }
                },
                {
                    "Visual Basic", new[] { "1" }
                },
                {
                    "Java", new[] { "1", "2", "3" }
                },
                {
                    "Go", new[] { "2", "3" }
                },
                {
                    "C", new[] { "3" }
                },
                {
                    "javaa", new[] { "3" }
                },
            }, result.Tags);
        }