コード例 #1
0
        public void ShouldBeAbleToGetMatchingGroups()
        {
            const string searchTerms   = "Search";
            var          separateTerms = new List <string>
            {
                "Search"
            };

            _groupRepositoryMock.Setup(x => x.GetGroupsMatchingTerms(separateTerms))
            .Returns(new List <Group>
            {
                new Group
                {
                    Name = "Search"
                }
            });

            _groupWeightCalculatorMock.Setup(x => x.CalculateWeights(
                                                 It.Is <IReadOnlyList <GroupDto> >(v => v.Count == 1 && v[0].Name == "Search"),
                                                 searchTerms,
                                                 separateTerms));

            var service = new GroupSearchService(_groupRepositoryMock.Object, _groupWeightCalculatorMock.Object);

            var result = service.Search(searchTerms, separateTerms);

            result.Should().HaveCount(1);
            result[0].Name.Should().Be("Search");
        }
コード例 #2
0
        public void ShouldReturnEmptyListWhenSearchTermsAreEmpty()
        {
            var service = new GroupSearchService(_groupRepositoryMock.Object, _groupWeightCalculatorMock.Object);

            var result = service.Search(string.Empty, new List <string>());

            result.Should().BeEmpty();
        }
コード例 #3
0
        public void ShouldReturnEmptyListWhenNoGroupIsFound()
        {
            const string searchTerms   = "Search";
            var          separateTerms = new List <string>
            {
                "Search"
            };

            _groupRepositoryMock.Setup(x => x.GetGroupsMatchingTerms(separateTerms))
            .Returns(new List <Group>());

            var service = new GroupSearchService(_groupRepositoryMock.Object, _groupWeightCalculatorMock.Object);

            var result = service.Search(searchTerms, separateTerms);

            result.Should().BeEmpty();
        }