public void GivenAnOutcodeAndOnlyOneLetterOfAUnit_WhenCallingValidation_ItReturnsAnError(string postCode)
        {
            var request = new SearchAddressRequest()
            {
                Postcode = postCode
            };

            _classUnderTest.ShouldHaveValidationErrorFor(x => x.Postcode, request).WithErrorMessage("Must provide at least the first part of the postcode.");
        }
        public void GivenAnOutcodeAndASectorAndTheFirstLetterOfTheUnit_WhenCallingValidation_ItReturnsNoErrors(string postCode)
        {
            var request = new SearchAddressRequest()
            {
                Postcode = postCode
            };

            _classUnderTest.ShouldNotHaveValidationErrorFor(x => x.Postcode, request);
        }
        public void GivenAnAddressStatusValueThatDoesntMatchAllowedOnes_WhenCallingValidation_ItReturnsAnError(string addressStatusVal)
        {
            var request = new SearchAddressRequest {
                AddressStatus = addressStatusVal
            };

            _classUnderTest.ShouldHaveValidationErrorFor(x => x.AddressStatus, request)
            .WithErrorMessage("Value for the parameter is not valid.");
        }
        public void GivenAValidPostcodeFolowedByRandomCharacters_WhenCallingValidation_ItReturnsAnError(string postCode)
        {
            var request = new SearchAddressRequest()
            {
                Postcode = postCode
            };

            _classUnderTest.ShouldHaveValidationErrorFor(x => x.Postcode, request).WithErrorMessage("Must provide at least the first part of the postcode.");
        }
        public void GivenARequestWithCrossRefCodeAndACrossRefValue_BothPresentOrBothAbsent_WhenCallingValidation_ItReturnsNoErrorRelatingToCrossReference(string crossRefCode, string value)
        {
            var request = new SearchAddressRequest()
            {
                CrossRefCode = crossRefCode, CrossRefValue = value
            };

            _classUnderTest.TestValidate(request).Result.Errors.Should().NotContain("You must provide both the code and a value, when searching by a cross reference");
        }
        public void GivenOnlyAnIncodeAndADistrictPartsOfThePostCode_WhenCallingValidation_ItReturnsAnError(string postCode)
        {
            var request = new SearchAddressRequest()
            {
                Postcode = postCode
            };

            _classUnderTest.ShouldHaveValidationErrorFor(x => x.Postcode, request).WithErrorMessage("Must provide at least the first part of the postcode.");
        }
        public void GivenAWhitespaceOrEmptyAddressStatusValue_WhenCallingValidation_ItReturnsAnError(string addressStatusVal)
        {
            var request = new SearchAddressRequest()
            {
                AddressStatus = addressStatusVal
            };

            _classUnderTest.ShouldHaveValidationErrorFor(x => x.AddressStatus, request);
        }
        public void GivenBothPartsOfPostCode_WhenCallingValidation_ItReturnsNoErrors(string postCode)
        {
            var request = new SearchAddressRequest()
            {
                Postcode = postCode
            };

            _classUnderTest.ShouldNotHaveValidationErrorFor(x => x.Postcode, request);
        }
        public void GivenARequestWithOnlyUsageCode_IfAddressScopeIsHackneyGazetteer_WhenCallingValidation_ItReturnsNoError(string usageCode)
        {
            var request = new SearchAddressRequest()
            {
                UsageCode = usageCode, AddressScope = _localGazetteer
            };

            _classUnderTest.TestValidate(request).ShouldNotHaveError();
        }
        public void GivenARequestWithOnlyAnAddressQuery_IfAddressScopeIsNational_WhenCallingValidation_ItReturnsNoError(string query)
        {
            var request = new SearchAddressRequest()
            {
                Query = query, AddressScope = _nationalGazetteer
            };

            _classUnderTest.TestValidate(request).ShouldNotHaveError();
        }
        public void GivenARequestWithOnlyAPostCode_IfAddressScopeIsNational_WhenCallingValidation_ItReturnsNoError(string postcode)
        {
            var request = new SearchAddressRequest()
            {
                Postcode = postcode, AddressScope = _nationalGazetteer
            };

            _classUnderTest.TestValidate(request).ShouldNotHaveError();
        }
        public void GivenARequestWithOnlyUSRN_IfAddressScopeIsNational_WhenCallingValidation_ItReturnsNoError(int usrn)
        {
            var request = new SearchAddressRequest()
            {
                USRN = usrn, AddressScope = _nationalGazetteer
            };

            _classUnderTest.TestValidate(request).ShouldNotHaveError();
        }
        public void GivenADateInTheCorrectFormat_WhenCallingValidation_ItReturnsNotError(string date)
        {
            var request = new SearchAddressRequest()
            {
                ModifiedSince = date
            };

            _classUnderTest.ShouldNotHaveValidationErrorFor(x => x.ModifiedSince, request);
        }
        public void GivenARequestWithNoMandatoryFields_IfAddressScopeIsNational_WhenCallingValidation_ItReturnsAnError(string buildingNumber)
        {
            var request = new SearchAddressRequest()
            {
                BuildingNumber = buildingNumber, AddressScope = _nationalGazetteer
            };

            _classUnderTest.TestValidate(request).ShouldHaveError().WithErrorMessage(
                "You must provide at least one of (query, uprn, usrn, postcode), when address_scope is 'national'.");
        }
        public void GivenARequestWithOnlyUsageCode_IfAddressScopeIsNational_WhenCallingValidation_ItReturnsAnError(string usageCode)
        {
            var request = new SearchAddressRequest()
            {
                UsageCode = usageCode, AddressScope = _nationalGazetteer
            };

            _classUnderTest.TestValidate(request).ShouldHaveError().WithErrorMessage(
                "You must provide at least one of (query, uprn, usrn, postcode), when address_scope is 'national'.");
        }
        public void GivenADateInTheWrongFormat_WhenCallingValidation_ItReturnsAnError(string date)
        {
            var request = new SearchAddressRequest()
            {
                ModifiedSince = date
            };

            _classUnderTest.ShouldHaveValidationErrorFor(x => x.ModifiedSince, request)
            .WithErrorMessage("Invalid date format. Please provide date in the format YYYY-MM-DD");
        }
        public void GivenRequestWithNegativePageSize_WhenCallingValidation_ItReturnsAnError()
        {
            var negativeValue = new Faker().Random.Int(-128, -1);

            var request = new SearchAddressRequest()
            {
                PageSize = negativeValue
            };

            _classUnderTest.ShouldHaveValidationErrorFor(x => x.PageSize, request)
            .WithErrorMessage("Invalid Page Size value. Page Size can not be a negative value");
        }
        public void GivenARequestWithCrossReference_WithoutAPostcodeOrUPRN_WhenCallingValidation_ItReturnsNoErrors()
        {
            const string code           = "TESTCT";
            const string referenceValue = "900000";

            var request = new SearchAddressRequest()
            {
                CrossRefCode = code, CrossRefValue = referenceValue
            };

            _classUnderTest.TestValidate(request).ShouldNotHaveError();
        }
예제 #19
0
        public async Task <Point> GeocodeZip(string zipCode)
        {
            var searchAddressRequest = new SearchAddressRequest {
                Query = zipCode, Limit = 100, CountrySet = "US"
            };
            var resp = await _mapService.GetSearchAddress(searchAddressRequest);

            var lat = resp.Result.Results[0].Position.Lat;
            var lon = resp.Result.Results[0].Position.Lon;

            return(new Point(lon, lat));
        }
        public void GivenInvalidFilterParameterWhoseNameMatchesOneOfSearchAddressRequestPropertiesThatAreNotUsedToGetOrFilterData_WhenCallingValidation_ItReturnsAnError(string queryParameter1, string queryParameter2, string postcode) //we also provide postcode, because it's mandatory and the other validation will interfere with this test if it's not put in.
        {
            var queryStringParameters = new List <string>()
            {
                queryParameter1, queryParameter2
            };
            var request = new SearchAddressRequest()
            {
                PostCode = postcode, RequestFields = queryStringParameters
            };

            _classUnderTest.ShouldHaveValidationErrorFor(x => x.RequestFields, request).WithErrorMessage("Invalid properties have been provided.");
        }
        public void GivenMultipleInvalidFilterParametersAndMandatoryParameter_WhenCallingValidation_ItReturnsAnError(string queryParameter1, string queryParameter2, string queryParameter3, string postcode)
        {
            var queryStringParameters = new List <string>()
            {
                queryParameter1, queryParameter2, queryParameter3
            };
            var request = new SearchAddressRequest()
            {
                PostCode = postcode, RequestFields = queryStringParameters
            };

            _classUnderTest.ShouldHaveValidationErrorFor(x => x.RequestFields, request).WithErrorMessage("Invalid properties have been provided.");
        }
        public void GivenOnlyValidFilterParameters_WhenCallingValidation_ItReturnsNoErrors(string queryParameter1, string queryParameter2, string postcode)
        {
            var queryStringParameters = new List <string>()
            {
                queryParameter1, queryParameter2
            };
            var request = new SearchAddressRequest()
            {
                PostCode = postcode, RequestFields = queryStringParameters
            };

            _classUnderTest.ShouldNotHaveValidationErrorFor(x => x.RequestFields, request);
        }
        public async Task GivenPageZero_WhenExecute_ReturnsPageOneAsync()
        {
            SetupValidatorToReturnValid();
            //arrange
            var request = new SearchAddressRequest
            {
                Page = 0
            };
            //act
            await _classUnderTest.ExecuteAsync(request).ConfigureAwait(true);

            //assert
            _searchAddressGateway.Verify(s => s.SearchAddresses(
                                             It.Is <SearchParameters>(i => i.Page.Equals(1))));
        }
        public void ExecuteAsync_CorrectlyConvertsAddressStatusIntoAList(string addressQuery, IEnumerable <string> expectedList)
        {
            SetupValidatorToReturnValid();
            var request = new SearchAddressRequest
            {
                Postcode      = "E8",
                AddressStatus = addressQuery
            };

            _searchAddressGateway.Setup(s => s.SearchAddresses(It.Is <SearchParameters>(i =>
                                                                                        i.AddressStatus.SequenceEqual(expectedList))))
            .ReturnsAsync((null, 0)).Verifiable();
            _classUnderTest.ExecuteAsync(request);
            _addressGateway.Verify();
        }
예제 #25
0
        public void GetSearchAddress()
        {
            var am = new AzureMapsToolkit.AzureMapsServices(_KEY);

            var searchAddressRequest = new SearchAddressRequest
            {
                Query = "15127 NE 24th Street,Redmond, WA 98052",
                Limit = 10
            };
            var resp = am.GetSearchAddress(searchAddressRequest).Result;

            Assert.Null(resp.Error);

            Assert.Equal(14.15, resp.Result.Results[0].Score);
        }
        public void GivenValidInput_WhenExecute_WillPassAllSearchParametersToTheSearchGateway()
        {
            SetupValidatorToReturnValid();

            var request = new SearchAddressRequest
            {
                Query                 = _faker.Address.FullAddress(),
                Postcode              = "RM3 0FS",
                AddressScope          = "HackneyGazetteer",
                Page                  = _faker.Random.Int(),
                Street                = _faker.Address.StreetAddress(),
                UsageCode             = _faker.Random.String2(4),
                UsagePrimary          = _faker.Random.Word(),
                AddressStatus         = "approved",
                BuildingNumber        = _faker.Address.BuildingNumber(),
                PageSize              = _faker.Random.Int(10, 40),
                UPRN                  = _faker.Random.Long(0, 9999999999),
                USRN                  = _faker.Random.Int(0, 9999999),
                IncludePropertyShells = _faker.Random.Bool(),
                CrossRefCode          = "123DEF",
                CrossRefValue         = "20000",
                ModifiedSince         = "2019-03-05"
            };

            _searchAddressGateway.Setup(s => s.SearchAddresses(It.Is <SearchParameters>(
                                                                   x =>
                                                                   x.Gazetteer == GlobalConstants.Gazetteer.Hackney &&
                                                                   x.OutOfBoroughAddress &&
                                                                   x.Page == request.Page &&
                                                                   x.Postcode == request.Postcode &&
                                                                   x.Street == request.Street &&
                                                                   x.Uprn == request.UPRN &&
                                                                   x.Usrn == request.USRN &&
                                                                   x.AddressStatus.SequenceEqual(new[] { "approved" }) &&
                                                                   x.BuildingNumber == request.BuildingNumber &&
                                                                   x.PageSize == request.PageSize &&
                                                                   x.UsageCode == request.UsageCode &&
                                                                   x.UsagePrimary == request.UsagePrimary &&
                                                                   x.IncludePropertyShells == request.IncludePropertyShells &&
                                                                   x.CrossRefCode == request.CrossRefCode &&
                                                                   x.CrossRefValue == request.CrossRefValue &&
                                                                   x.AddressQuery == request.Query &&
                                                                   x.ModifiedSince.Value.ToString("yyyy-MM-dd") == request.ModifiedSince)))
            .ReturnsAsync((new List <string>(), 1)).Verifiable();

            _classUnderTest.ExecuteAsync(request);
            _addressGateway.Verify();
        }
        public void ExecuteAsync_CorrectlyMapsAddressScopeToGazetteerAndOutOfBorough(string addressScope,
                                                                                     GlobalConstants.Gazetteer expectedGazetteer, bool expectedOutOfBorough)
        {
            SetupValidatorToReturnValid();
            var request = new SearchAddressRequest
            {
                Postcode     = "E8",
                AddressScope = addressScope
            };

            _searchAddressGateway.Setup(s => s.SearchAddresses(It.Is <SearchParameters>(i =>
                                                                                        i.Gazetteer.Equals(expectedGazetteer) && i.OutOfBoroughAddress.Equals(expectedOutOfBorough))))
            .ReturnsAsync((null, 0)).Verifiable();
            _classUnderTest.ExecuteAsync(request);
            _addressGateway.Verify();
        }
예제 #28
0
 public async Task <HttpResponseMessage> Search(string zipcode)
 {
     try
     {
         var request = new SearchAddressRequest()
         {
             ZipCode = zipcode
         };
         var response = _serviceAddress.Search(request);
         return(await ResponseAsync(response, _serviceAddress));
     }
     catch (Exception ex)
     {
         return(await ResponseExceptionAsync(ex));
     }
 }
예제 #29
0
        public void GivenPageZero_WhenExecuteAsync_ReturnsPageOne()
        {
            SetupValidatorToReturnValid();
            //arrange
            var request = new SearchAddressRequest
            {
                Page = 0
            };

            //act
            _classUnderTest.ExecuteAsync(request);

            //assert
            _fakeGateway.Verify(s => s.SearchAddresses(
                                    It.Is <SearchParameters>(i => i.Page.Equals(1))));
        }
예제 #30
0
        public async Task Locate(MaskRequest request)
        {
            var searchAddressRequest = new SearchAddressRequest
            {
                Query      = $"{request.Organization.AddressLine1} {request.Organization.City} {request.Organization.State} {request.Organization.ZipCode}",
                Limit      = 1,
                CountrySet = "US"
            };

            var resp = await _mapService.GetSearchAddress(searchAddressRequest);

            var lat = resp.Result.Results[0].Position.Lat;
            var lon = resp.Result.Results[0].Position.Lon;

            request.Organization.Geolocation = new Point(lon, lat);
        }
 private SearchAddressResponse CallSearchAddress(SearchAddressRequest request)
 {
     if (channel == null || channel.State != CommunicationState.Opened)
     {
         var rc = CallOpen();
         if (LastRC != ZustellServiceRC.OK)
         {
             return null;
         }
     }
     return CallService(() => client.SearchAddress(request));
 }
        /// <summary>
        /// Searches for the an address entry.
        /// </summary>
        /// <param name="searchTarget">The search target.</param>
        /// <returns>The list of PersonDataType Entries</returns>
        public List<PersonDataType> SearchAddress(SearchAddressType searchTarget)
        {
            List<PersonDataType> addrBook = new List<PersonDataType>();
            LastRC = ZustellServiceRC.OK;
            SearchAddressRequest requ = new SearchAddressRequest()
            {
                SearchAddress = searchTarget
            };
            Log.Debug("Request: {@SearchAddressType}", CallerInfo.Create(), requ.SearchAddress);

            var resp = CallSearchAddress(requ);
            if (LastRC == ZustellServiceRC.OK)
            {
                addrBook = resp.AddressBook.ToList();
                Log.Debug("Response: {@PersonDataType}", CallerInfo.Create(), addrBook);
            }
            return addrBook;
        }