public void SetUp()
        {
            _groupService     = new Mock <IGroupRepository>();
            _attributeService = new Mock <MPServices.IAttributeRepository>();

            _config = new Mock <IConfigurationWrapper>();

            _config.Setup(mocked => mocked.GetConfigIntValue("MaxGroupSearchResults")).Returns(MaxGroupSearchResults);
            _config.Setup(mocked => mocked.GetConfigValue("InMarketZipCodes")).Returns(InMarketZipCodes);
            _config.Setup(mocked => mocked.GetConfigIntValue("WeekendTimesAttributeTypeId")).Returns(WeekendTimes);
            _config.Setup(mocked => mocked.GetConfigIntValue("WeekdayTimesAttributeTypeId")).Returns(WeekdayTimes);
            _config.Setup(mocked => mocked.GetConfigIntValue("ParticipantGoalAttributeTypeId")).Returns(ParticipantGoal);
            _config.Setup(mocked => mocked.GetConfigIntValue("GenderTypeAttributeTypeId")).Returns(Gender);
            _config.Setup(mocked => mocked.GetConfigIntValue("MaritalStatusTypeAttributeTypeId")).Returns(MaritalStatus);

            _config.Setup(mocked => mocked.GetConfigIntValue("GroupGoalConnectWithCommunity")).Returns(GroupGoalConnectWithCommunity);
            _config.Setup(mocked => mocked.GetConfigIntValue("GroupGoalMakeFriends")).Returns(GroupGoalMakeFriends);
            _config.Setup(mocked => mocked.GetConfigIntValue("GroupGoalLearnAndGrow")).Returns(GroupGoalLearnAndGrow);
            _config.Setup(mocked => mocked.GetConfigIntValue("GroupGoalMentorOthers")).Returns(GroupGoalMentorOthers);

            _config.Setup(mocked => mocked.GetConfigIntValue("ParticipantGoalNotSure")).Returns(ParticipantGoalNotSure);
            _config.Setup(mocked => mocked.GetConfigIntValue("ParticipantGoalGrowSpiritually")).Returns(ParticipantGoalGrowSpiritually);
            _config.Setup(mocked => mocked.GetConfigIntValue("ParticipantGoalLearnFromSomeone")).Returns(ParticipantGoalLearnFromSomeone);
            _config.Setup(mocked => mocked.GetConfigIntValue("ParticipantGoalMakeFriends")).Returns(ParticipantGoalMakeFriends);

            _fixture = new GroupSearchService(_groupService.Object, _attributeService.Object, _config.Object);
        }
Example #2
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");
        }
Example #3
0
        public void ShouldReturnEmptyListWhenSearchTermsAreEmpty()
        {
            var service = new GroupSearchService(_groupRepositoryMock.Object, _groupWeightCalculatorMock.Object);

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

            result.Should().BeEmpty();
        }
Example #4
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();
        }
        public GroupsModule(
            GroupService groupService,
            GroupValidator validator,
            ILogger logger,
            AccessService accessService,
            ClientService clientService,
            GrainService grainService,
            GroupSearchService groupSearchService,
            IAppConfiguration appConfiguration = null) : base("/v1/groups", logger, validator, accessService, appConfiguration)
        {
            _groupService       = groupService;
            _clientService      = clientService;
            _grainService       = grainService;
            _groupSearchService = groupSearchService;

            Get("/",
                async _ => await GetGroups().ConfigureAwait(false),
                null,
                "GetGroups");
            base.Get("/{groupName}",
                     async _ => await GetGroup().ConfigureAwait(false),
                     null,
                     "GetGroup");

            Post("/",
                 async _ => await AddGroup().ConfigureAwait(false),
                 null,
                 "AddGroup");

            Post("/UpdateGroups",
                 async _ => await UpdateGroupList().ConfigureAwait(false),
                 null,
                 "UpdateGroups");

            Patch("/{groupName}",
                  async parameters => await this.UpdateGroup(parameters).ConfigureAwait(false),
                  null,
                  "UpdateGroup");

            base.Delete("/{groupName}",
                        async p => await this.DeleteGroup(p).ConfigureAwait(false),
                        null,
                        "DeleteGroup");

            // group->role mappings
            Get("/{groupName}/roles",
                async _ => await GetRolesFromGroup().ConfigureAwait(false),
                null,
                "GetRolesFromGroup");

            Get("/{groupName}/{grain}/{securableItem}/roles",
                async p => await GetRolesForGroup(p).ConfigureAwait(false),
                null,
                "GetRolesForGroup");

            Post("/{groupName}/roles",
                 async p => await AddRolesToGroup(p).ConfigureAwait(false),
                 null,
                 "AddRolesToGroup");

            Delete("/{groupName}/roles",
                   async p => await DeleteRolesFromGroup(p).ConfigureAwait(false),
                   null,
                   "DeleteRolesFromGroup");

            // (custom) group->user mappings
            Get("/{groupName}/users",
                async _ => await GetUsersFromGroup().ConfigureAwait(false),
                null,
                "GetUsersFromGroup");

            Post("/{groupName}/users",
                 async p => await AddUsersToGroup(p).ConfigureAwait(false),
                 null,
                 "AddUserToGroup");

            Delete("/{groupName}/users",
                   async _ => await DeleteUserFromGroup().ConfigureAwait(false),
                   null,
                   "DeleteUserFromGroup");

            // child groups
            Get("/{groupName}/groups",
                async p => await GetChildGroups(p).ConfigureAwait(false),
                null,
                "GetChildGroups");

            Post("/{groupName}/groups",
                 async p => await AddChildGroups(p).ConfigureAwait(false),
                 null,
                 "AddChildGroups");

            Delete("/{groupName}/groups",
                   async p => await RemoveChildGroups(p).ConfigureAwait(false),
                   null,
                   "RemoveChildGroups");
        }