public async Task WhenGetAddressesCalledAndCallFails_ThenReturnNull()
        {
            _restClient.GetAsync <string>(Arg.Any <string>())
            .ReturnsForAnyArgs(string.Empty);

            var service = new AddressSearchService(new OptionsWrapper <AddressSearchServiceSettings>(new AddressSearchServiceSettings()), _restClient);

            var result = await service.GetAddress("test");

            result.Should().BeNull();
        }
        public async Task WhenGetAddressCalledAndNoAddressFound_ThenReturnNull()
        {
            _restClient.LastResponse = new RestClient.APIResponse(new HttpResponseMessage())
            {
                IsSuccess = false
            };

            _restClient.GetAsync <string>(Arg.Any <string>())
            .ReturnsForAnyArgs(JsonConvert.SerializeObject(new List <PostalAddressModel>()));

            var service = new AddressSearchService(new OptionsWrapper <AddressSearchServiceSettings>(new AddressSearchServiceSettings()), _restClient);

            var result = await service.GetAddress("test");

            result.Should().BeNull();
        }
        public async Task WhenGetAddressCalled_ThenCorrectUrlIsGenerated()
        {
            _restClient.GetAsync <IEnumerable <PostalAddressModel> >(Arg.Any <string>())
            .ReturnsForAnyArgs(new List <PostalAddressModel>());

            var service = new AddressSearchService(new OptionsWrapper <AddressSearchServiceSettings>(new AddressSearchServiceSettings
            {
                Key = "1",
                AddressIdentifierPattern = "2",
                FindAddressesBaseUrl     = "3",
                RetrieveAddressBaseUrl   = "4"
            }), _restClient);

            await service.GetAddress("test");

            await _restClient.Received().GetAsync <IEnumerable <PostalAddressModel> >(Arg.Is("4&Key=1&Id=test"));
        }
        public async Task WhenGetAddressCalled_ThenReturnResult()
        {
            _restClient.GetAsync <IEnumerable <PostalAddressModel> >(Arg.Any <string>())
            .ReturnsForAnyArgs(new List <PostalAddressModel>
            {
                new PostalAddressModel
                {
                    Id = "test"
                }
            });

            var service = new AddressSearchService(new OptionsWrapper <AddressSearchServiceSettings>(new AddressSearchServiceSettings()), _restClient);

            var result = await service.GetAddress("test");

            result.Should().BeOfType <PostalAddressModel>();
        }