// TODO: I don't like that this func mutates the passed parameter, create a model and return it.
        private async Task <SawmillGeocodeRequest> GeocodeLocationAsync(SawmillGeocodeRequest location)
        {
            if (location.Status == SawmillStatus.RequiresLookup)
            {
                // TODO: Test that this caches.
                logger?.LogInformation((int)LogEventIds.CheckingCache, "Looking up locations in L1/L2 caches");
                location = await locationCache.LookupAsync(location.Source);
            }

            var qualityStatus = addressQualityChecker.StatusGuessFromSourceQuality(location.Source);

            if (qualityStatus != AddressQualityStatus.OK)
            {
                location.Status = MapQualityStatus(qualityStatus);
            }

            if (location.Status == SawmillStatus.RequiresGeocoding || location.Status == SawmillStatus.TemporaryGeocodeError)
            {
                // TODO: We might need to record the last time a geocoding was attempted and how many tries if this was a temp error so we don't keep retrying.
                var result = await geocodeManager.GeocodeAddressAsync(location.Source);

                // TODO: Insert additional responses into cache here plus expiry times dependent on the status.
                if (result.Status == AddressLookupStatus.Geocoded || result.Status == AddressLookupStatus.ZeroResults)
                {
                    // TODO: Add cache inserting.
                    // locationCache.InsertAsync
                }

                // TODO: Geocoder should return a text description of the errors so we can present to the user.
                location.Status       = MapGeocoderStatus(result.Status);
                location.GeocoderUsed = result.GeocoderId;
                if (location.Status == SawmillStatus.Geocoded)
                {
                    location.Responses = result.Locations;
                }
            }

            return(location);
        }
        public void Address_quality_can_be_calculated_correctly(string source, AddressQualityStatus expected)
        {
            var status = addressQualityChecker.StatusGuessFromSourceQuality(source);

            Assert.Equal(expected, status);
        }