Esempio n. 1
0
        public void ShouldGetOpenOrgGroupConnectorsAndFilterOutAnywhere()
        {
            const int initiativeId        = 4;
            const int anywhereId          = 4;
            var       fakeGroupConnectors = new List <MpGroupConnector>
            {
                new MpGroupConnector
                {
                    Name = "groupConnector1",
                    PreferredLaunchSiteId = 2,
                    PreferredLaunchSite   = "Oakley"
                },
                new MpGroupConnector
                {
                    Name = "groupConnector2",
                    PreferredLaunchSiteId = 4,
                    PreferredLaunchSite   = "Anywhere"
                },
            };

            _groupRepository.Setup(m => m.GetGroupConnectorsForOpenOrganizations(initiativeId))
            .Returns(fakeGroupConnectors);
            _config.Setup(m => m.GetConfigIntValue("AnywhereCongregation")).Returns(anywhereId);

            var res = _fixture.GetGroupConnectorsForOpenOrganizations(initiativeId);

            Assert.AreEqual(1, res.Count);
            Assert.AreEqual("groupConnector1", res.First().Name);
        }
        public IHttpActionResult GetGetGroupConnectorsOpenOrgs(int initiativeId)
        {
            try
            {
                var groupConnectors = _groupConnectorService.GetGroupConnectorsForOpenOrganizations(initiativeId);

                if (groupConnectors == null)
                {
                    return(NotFound());
                }
                return(Ok(groupConnectors));
            }
            catch (Exception e)
            {
                const string msg = "GoVolunteerController.GetGetGroupConnectorsOpenOrgs";
                logger.Error(msg, e);
                var apiError = new ApiErrorDto(msg, e);
                throw new HttpResponseException(apiError.HttpResponseMessage);
            }
        }