public async Task Get404WhenUPRNIsNotProvided()
        {
            var uprn = _faker.Random.Int();

            TestEfDataHelper.InsertCrossReference(DatabaseContext, uprn);

            var url      = new Uri($"api/v1/properties/crossreferences", UriKind.Relative);
            var response = await Client.GetAsync(url).ConfigureAwait(true);

            response.StatusCode.Should().Be(404);
        }
Exemple #2
0
        public void ItWillReturnAListOfCrossReferencesUsingAUprn()
        {
            var uprn = _faker.Random.Long();

            var savedCrossRef = TestEfDataHelper.InsertCrossReference(DatabaseContext, uprn);

            var response = _classUnderTest.GetAddressCrossReference(uprn);

            response.Should().NotBeNull();

            response.First().UPRN.Should().Be(uprn);
            response.First().Should().BeEquivalentTo(savedCrossRef.ToDomain());
        }
        public async Task GetCrossReferenceAddressReturns200()
        {
            var uprn = _faker.Random.Int();

            TestEfDataHelper.InsertCrossReference(DatabaseContext, uprn);

            var url      = new Uri($"api/v1/properties/{uprn}/crossreferences", UriKind.Relative);
            var response = await Client.GetAsync(url).ConfigureAwait(true);

            response.StatusCode.Should().Be(200);

            var convertedResponse = await ConvertToCrossReferenceResponseObject(response).ConfigureAwait(true);

            convertedResponse.StatusCode.Should().Be(200);
        }
        public async Task GetDetailedCrossReferenceAddressRecord()
        {
            var uprn   = _faker.Random.Int();
            var record = _fixture.Build <CrossReference>()
                         .With(add => add.UPRN, uprn)
                         .Create();

            TestEfDataHelper.InsertCrossReference(DatabaseContext, uprn, record);

            var url      = new Uri($"api/v1/properties/{uprn}/crossreferences", UriKind.Relative);
            var response = await Client.GetAsync(url).ConfigureAwait(true);

            var apiResponse = await ConvertToCrossReferenceResponseObject(response).ConfigureAwait(true);

            var recordReturned = apiResponse.Data.AddressCrossReferences.FirstOrDefault();

            recordReturned.UPRN.Should().Be(uprn);
            recordReturned.Name.Should().Be(record.Name);
            recordReturned.Value.Should().Be(record.Value);
            recordReturned.Code.Should().Be(record.Code);
            recordReturned.CrossRefKey.Should().Be(record.CrossRefKey);
            recordReturned.EndDate.Value.Date.Should().Be(record.EndDate.Value.Date);
        }