Пример #1
0
        public async Task CanFindRrAdres()
        {
            //Arrange
            string existingNisCode      = Generate.Generate.NISCode.Generate(_random);
            string existingGemeentenaam = "Springfield";
            int    existingStraatnaamId = Generate.Generate.VbrObjectIDInt.Generate(_random);
            string existingStraatnaam   = "Evergreen Terrace";
            var    streetNameId         = Guid.NewGuid();

            AddressMatchRequest request = new AddressMatchRequest().WithPostcodeAndRrStraatcode();

            request.Huisnummer = "15";

            var gemeente = _latest.ArrangeLatestGemeente(existingNisCode, existingGemeentenaam).First();
            var straat   = _latest.ArrangeLatestStraatnaam(existingNisCode, existingGemeentenaam, existingStraatnaamId.ToString(), existingStraatnaam, streetNameId).First();

            var mappedAdressen = _kadRrService
                                 .Arrange(Produce.Many(Generate.Generate.tblHuisNummer.Select(x => x.WithStraatNaamId(streetNameId))),
                                          (when, x) => when.AdresMappingExistsFor(x, request.Huisnummer, request.Index, request.RrStraatcode, request.Postcode));

            //Act
            var response = (AddressMatchCollection)((OkObjectResult)await Send(request)).Value;

            //Assert
            response.Should().NotBeNull();
            response.Should().HaveMatches(Math.Min(mappedAdressen.Count(), 10));
            AdresMatchItem firstMatch = response.AdresMatches.First();

            firstMatch.Should().HaveGemeente()
            .Which.Should().HaveGemeentenaam(existingGemeentenaam)
            .And.HaveObjectId(existingNisCode);
            firstMatch.Should().HaveStraatnaam()
            .Which.Should().HaveStraatnaam(existingStraatnaam)
            .And.HaveObjectId(existingStraatnaamId.ToString());
            firstMatch.Should().HaveVolledigAdres()
            .Which.Should().HaveGeografischeNaam($"{existingStraatnaam} {mappedAdressen.First().HouseNumber} bus {mappedAdressen.First().BoxNumber}, {mappedAdressen.First().PostalCode} {existingGemeentenaam}");
        }