public async Task UsingQueryParametersReturnsAPaginatedResponse()
        {
            var residents = new List <ResidentInformation>
            {
                E2ETestHelpers.AddPersonWithRelatedEntitiesToDb(UHContext, houseRef: "123", personNo: 1),
                E2ETestHelpers.AddPersonWithRelatedEntitiesToDb(UHContext, houseRef: "234", personNo: 1),
                E2ETestHelpers.AddPersonWithRelatedEntitiesToDb(UHContext, houseRef: "345", personNo: 1)
            };

            var uri      = new Uri("api/v1/households?cursor=1231&limit=10", UriKind.Relative);
            var response = Client.GetAsync(uri);

            var statusCode = response.Result.StatusCode;

            statusCode.Should().Be(200);

            var content       = response.Result.Content;
            var stringContent = await content.ReadAsStringAsync().ConfigureAwait(true);

            var convertedResponse = JsonConvert.DeserializeObject <ResidentInformationList>(stringContent);

            var expectedResponse = residents.OrderBy(resident => resident.HouseReference).TakeLast(2).ToList();

            convertedResponse.Residents.Count.Should().Be(2);
            convertedResponse.Residents[0].HouseReference.Should().Be(expectedResponse[0].HouseReference);
            convertedResponse.Residents[1].HouseReference.Should().Be(expectedResponse[1].HouseReference);
        }
Example #2
0
        public async Task GetResidentByIdReturnsTheCorrectInformation()
        {
            var personNo = 11;
            var houseRef = "XXXtestRef";

            var expectedResponse = E2ETestHelpers.AddPersonWithRelatedEntitiesToDb(UHContext, houseRef, personNo);

            var uri        = new Uri($"api/v1/households/{houseRef}/people/{personNo}", UriKind.Relative);
            var response   = Client.GetAsync(uri);
            var statusCode = response.Result.StatusCode;

            statusCode.Should().Be(200);

            var content       = response.Result.Content;
            var stringContent = await content.ReadAsStringAsync().ConfigureAwait(true);

            var convertedResponse = JsonConvert.DeserializeObject <ResidentInformation>(stringContent);

            convertedResponse.Should().BeEquivalentTo(expectedResponse);
        }
        public async Task FirstNameLastNameQueryParametersReturnsMatchingResidentRecordsFromhousing()
        {
            var expectedResidentResponseOne   = E2ETestHelpers.AddPersonWithRelatedEntitiesToDb(UHContext, firstname: "ciasom", lastname: "tessellate");
            var expectedResidentResponseTwo   = E2ETestHelpers.AddPersonWithRelatedEntitiesToDb(UHContext, firstname: "ciasom", lastname: "shape");
            var expectedResidentResponseThree = E2ETestHelpers.AddPersonWithRelatedEntitiesToDb(UHContext);

            var uri      = new Uri("api/v1/households?first_name=ciasom&last_name=tessellate", UriKind.Relative);
            var response = Client.GetAsync(uri);

            var statusCode = response.Result.StatusCode;

            statusCode.Should().Be(200);

            var content       = response.Result.Content;
            var stringContent = await content.ReadAsStringAsync().ConfigureAwait(true);

            var convertedResponse = JsonConvert.DeserializeObject <ResidentInformationList>(stringContent);

            convertedResponse.Residents.Count.Should().Be(1);
            convertedResponse.Residents.Should().ContainEquivalentOf(expectedResidentResponseOne);
        }
        public async Task IfNoQueryParametersReturnsAllResidentRecordsFromhousingWithActiveTenancy()
        {
            var expectedResidentResponseOne   = E2ETestHelpers.AddPersonWithRelatedEntitiesToDb(UHContext);
            var expectedResidentResponseTwo   = E2ETestHelpers.AddPersonWithRelatedEntitiesToDb(UHContext, isTerminated: true);
            var expectedResidentResponseThree = E2ETestHelpers.AddPersonWithRelatedEntitiesToDb(UHContext);


            var uri      = new Uri("api/v1/households?active_tenancies_only=true", UriKind.Relative);
            var response = Client.GetAsync(uri);

            var statusCode = response.Result.StatusCode;

            statusCode.Should().Be(200);

            var content       = response.Result.Content;
            var stringContent = await content.ReadAsStringAsync().ConfigureAwait(true);

            var convertedResponse = JsonConvert.DeserializeObject <ResidentInformationList>(stringContent);

            convertedResponse.Residents.Count.Should().Be(2);
            convertedResponse.Residents.Should().ContainEquivalentOf(expectedResidentResponseOne);
            convertedResponse.Residents.Should().ContainEquivalentOf(expectedResidentResponseThree);
        }
        public async Task AddressQueryParametersReturnsMatchingResidentsRecordsFromhousing()
        {
            var matchingResidentOne  = E2ETestHelpers.AddPersonWithRelatedEntitiesToDb(UHContext, addressLines: "1 Seasame street, Hackney, LDN");
            var matchingResidentTwo  = E2ETestHelpers.AddPersonWithRelatedEntitiesToDb(UHContext, addressLines: "1 Seasame street");
            var nonMatchingResident1 = E2ETestHelpers.AddPersonWithRelatedEntitiesToDb(UHContext);
            var nonMatchingResident2 = E2ETestHelpers.AddPersonWithRelatedEntitiesToDb(UHContext, addressLines: "2 Seasame street, Hackney, LDN");
            var nonMatchingResident3 = E2ETestHelpers.AddPersonWithRelatedEntitiesToDb(UHContext);

            var uri      = new Uri("api/v1/households?address=1 Seasame street", UriKind.Relative);
            var response = Client.GetAsync(uri);

            var statusCode = response.Result.StatusCode;

            statusCode.Should().Be(200);

            var content       = response.Result.Content;
            var stringContent = await content.ReadAsStringAsync().ConfigureAwait(true);

            var convertedResponse = JsonConvert.DeserializeObject <ResidentInformationList>(stringContent);

            convertedResponse.Residents.Count.Should().Be(2);
            convertedResponse.Residents.Should().ContainEquivalentOf(matchingResidentOne);
            convertedResponse.Residents.Should().ContainEquivalentOf(matchingResidentTwo);
        }