public void DeleteTaxonomyWhereTaxonomyStillLinkedToServiceThrowsError()
        {
            var id = Randomm.Create <int>();
            var serviceTaxonomies = Randomm.CreateMany <ServiceTaxonomyDomain>().ToList();

            _mockTaxonomyGateway.Setup(g => g.GetServiceTaxonomies(It.IsAny <int>())).Returns(serviceTaxonomies);
            _classUnderTest.Invoking(c => c.ExecuteDelete(id)).Should().Throw <ServiceTaxonomyExistsException>();
        }
        public void ReturnsHelpRequests() //Wrap up
        {
            var responseData = Randomm.CreateMany <TaxonomyEntity>().ToList();

            _mockTaxonomiesGateway.Setup(g => g.GetTaxonomies(It.IsAny <string>())).Returns(responseData);
            var expectedResponse = responseData.ToResponse();
            var response         = _classUnderTest.ExecuteGet(null);

            response.Should().NotBeNull();
            response.Should().BeEquivalentTo(expectedResponse);
        }
示例#3
0
        public void ReturnsResponseWithStatus()
        {
            var expected         = Randomm.CreateMany <TaxonomyEntity>().ToList();
            var expectedResponse = expected.ToResponse();

            _mockUseCase.Setup(u => u.ExecuteGet(It.IsAny <string>())).Returns(expectedResponse);
            var response = _classUnderTest.GetTaxonomies() as OkObjectResult;

            response.Should().NotBeNull();
            response.StatusCode.Should().Be(200);
            response.Value.Should().BeEquivalentTo(expectedResponse);
        }
        public void ReturnsSearchResponseWith200Status()
        {
            var expected     = Randomm.CreateMany <OrganisationDomain>(10).ToResponse();
            var requestParam = Randomm.Create <OrganisationSearchRequest>();

            _mockUseCase.Setup(u => u.ExecuteGet(It.Is <OrganisationSearchRequest>(p => p == requestParam))).ReturnsAsync(expected);
            var response = _classUnderTest.SearchOrganisations(requestParam) as OkObjectResult;

            response.Should().NotBeNull();
            response.StatusCode.Should().Be(200);
            response.Value.Should().BeEquivalentTo(expected);
        }
        public void ReturnsOrganisations()
        {
            var organisations = Randomm.CreateMany <OrganisationDomain>(10).ToList();
            var searchParams  = Randomm.Create <OrganisationSearchRequest>();

            _mockOrganisationsGateway.Setup(g => g.SearchOrganisations(It.IsAny <OrganisationSearchRequest>())).ReturnsAsync(organisations);
            var expectedResponse = organisations.ToResponse();
            var response         = _classUnderTest.ExecuteGet(searchParams).Result;

            response.Should().NotBeNull();
            response.Should().BeEquivalentTo(expectedResponse);
        }
示例#6
0
        public void ReturnsListAllResponseWith200Status()
        {
            var expected = new TaxonomyResponseList()
            {
                Categories   = Randomm.CreateMany <TaxonomyResponse>().ToList(),
                Demographics = Randomm.CreateMany <TaxonomyResponse>().ToList()
            };

            _mockUseCase.Setup(u => u.ExecuteGet(It.Is <int?>(p => p == null))).Returns(expected);
            var response = _classUnderTest.ListTaxonomies(null) as OkObjectResult;

            response.Should().NotBeNull();
            response.StatusCode.Should().Be(200);
            response.Value.Should().BeEquivalentTo(expected);
        }
示例#7
0
        public void ReturnsListResponseWith200Status()
        {
            var expected = new AnalyticsResponseList()
            {
                AnalyticEvents = Randomm.CreateMany <AnalyticsResponse>().ToList()
            };
            var requestParam = Randomm.Create <AnalyticsRequest>();

            _mockUseCase.Setup(u => u.ExecuteGet(It.Is <AnalyticsRequest>(p => p == requestParam))).Returns(expected);
            var response = _classUnderTest.GetAnalytics(requestParam) as OkObjectResult;

            response.Should().NotBeNull();
            response.StatusCode.Should().Be(200);
            response.Value.Should().BeEquivalentTo(expected);
        }
        public void ReturnsTaxonomiesByVocab()
        {
            var taxonomies = Randomm.CreateMany <TaxonomyDomain>().ToList();

            taxonomies[0].Vocabulary = "category";
            taxonomies[0].Vocabulary = "demographic";
            taxonomies[0].Vocabulary = "category";
            _mockTaxonomyGateway.Setup(g => g.GetTaxonomiesByVocabulary(It.IsAny <string>())).Returns(taxonomies);
            var expectedResponse = new TaxonomyResponseList()
            {
                Categories   = taxonomies.Where(x => x.Vocabulary == "category").ToList().ToResponse(),
                Demographics = new List <TaxonomyResponse>()
            };
            var response = _classUnderTest.ExecuteGet(1);

            response.Should().NotBeNull();
            response.Should().BeEquivalentTo(expectedResponse);
        }
示例#9
0
        public void GetAnalyticsEventsReturnsMatchingAnalyticsEvents()
        {
            var analyticsEvents = Randomm.CreateMany <AnalyticsEventDomain>().ToList();
            var service         = Randomm.Create <ServiceDomain>();

            service.OrganisationId     = 123;
            analyticsEvents[0].Service = service;
            analyticsEvents[1].Service = service;
            analyticsEvents[2].Service = service;

            var analyticsRequest = new AnalyticsRequest
            {
                OrganisationId = 123
            };

            _mockAnalyticsGateway.Setup(g => g.GetAnalyticsEvents(It.IsAny <AnalyticsEventQuery>())).Returns(analyticsEvents);
            var expectedResponse = analyticsEvents.ToResponse();
            var response         = _classUnderTest.ExecuteGet(analyticsRequest);

            response.Should().NotBeNull();
            response.Should().BeEquivalentTo(expectedResponse);
            response.AnalyticEvents.Count.Should().Be(3);
        }