示例#1
0
        private static async Task AssertExpectedAndActualJsonTheSame(HttpResponseMessage response,
                                                                     ResidentInformationResponse expectedResponse)
        {
            var stringContent = await response.Content.ReadAsStringAsync().ConfigureAwait(true);

            stringContent.Should().BeEquivalentTo(expectedResponse.ToJson());
        }
示例#2
0
        public async Task ListEndpointReturnsRecordsFromFromEachApi()
        {
            var expectedResponse = new ResidentInformationResponse();

            var claimants = _fixture.Create <AcademyClaimantResponse>();

            HelperMethods.SetupAcademyResponseWithClaimants(claimants.ToJson(), MockAcademyAPI);
            var expectedAcademyResponses = HelperMethods.MapToResponse(claimants);

            var households = _fixture.Create <HousingApiResponse>();

            HelperMethods.SetupHousingResponseWithHouseholds(households.ToJson(), MockHousingApi);
            var expectedHousingResponse = HelperMethods.MapToResponse(households);

            var residents = _fixture.Create <MosaicResidentResponse>();

            HelperMethods.SetupMosaicResponseWithClaimants(residents.ToJson(), MockMosaicApi);
            var expectedResidentsResponse = HelperMethods.MapToResponse(residents);

            expectedResponse.Results = expectedAcademyResponses.Concat(expectedHousingResponse).Concat(expectedResidentsResponse).ToList();

            var url      = new Uri("/api/v1/residents?first_name=joe", UriKind.Relative);
            var response = await Client.GetAsync(url).ConfigureAwait(true);

            response.StatusCode.Should().Be(200);
            await AssertExpectedAndActualJsonTheSame(response, expectedResponse).ConfigureAwait(true);
        }
示例#3
0
        public async Task ListContactsReturnsAResponse()
        {
            var stubbedContactInformation = new ResidentInformationResponse()
            {
                Results = _fixture.Build <ResidentInformationResult>().With(x => x.Data, _fixture.Create <AcademyClaimantInformation>()).CreateMany().ToList()
            };

            var rqp = new ResidentQueryParam()
            {
                FirstName = "ciasom",
                LastName  = "tessellate",
                Postcode  = "E8 1DY",
                Address   = "1 Montage Street"
            };

            _mockListContactsUseCase.Setup(x => x.Execute(rqp)).Returns(Task.FromResult(stubbedContactInformation));
            var response = await _classUnderTest.ListContactsAsync(rqp).ConfigureAwait(true) as OkObjectResult;

            response.Should().NotBeNull();
            response.StatusCode.Should().Be(200);
            response.Value.Should().BeEquivalentTo(stubbedContactInformation);
        }