示例#1
0
        public void Api_Submit_ValidLocationRequest_ReturnsCorrectWoeid(string cityName,
                                                                        int expectedCount,
                                                                        int expectedWoeid,
                                                                        ApiProxy apiProxy,
                                                                        ILocationRequest locationRequest,
                                                                        ILocationResponse locationResponse)
        {
            $"Given a cityName value of {cityName}"
            .x(() => locationRequest = new LocationRequest {
                CityName = cityName
            });

            "And an ApiProxy"
            .x(() => apiProxy = new ApiProxy(_metaWeatherService));

            "When the location request is submitted"
            .x(async() => locationResponse =
                   await apiProxy.SubmitLocationRequest(locationRequest).ConfigureAwait(false));

            $"Then the location response should return HttpStatusCode.OK), CityName {cityName} and WoeId {expectedWoeid}"
            .x(() =>
            {
                using (new AssertionScope())
                {
                    locationResponse.StatusCode.Should().Be(HttpStatusCode.OK);
                    locationResponse.Locations.Should().HaveCount(expectedCount);
                    locationResponse.Locations[0].WoeId.Should().Be(expectedWoeid);
                }
            });
        }
示例#2
0
        public void Api_Submit_InvalidLocationRequest_ReturnsNotFound(string cityName,
                                                                      ApiProxy apiProxy,
                                                                      ILocationRequest locationRequest,
                                                                      ILocationResponse locationResponse)
        {
            $"Given a cityName value of {cityName}"
            .x(() => locationRequest = new LocationRequest {
                CityName = cityName
            });

            "And an ApiProxy".x(() => apiProxy = new ApiProxy(_metaWeatherService));

            "When the location request is submitted"
            .x(async() => locationResponse =
                   await apiProxy.SubmitLocationRequest(locationRequest).ConfigureAwait(false));

            "Then the location response should return HttpStatusCode.NotFound, and Locations should be empty"
            .x(() =>
            {
                using (new AssertionScope())
                {
                    locationResponse.StatusCode.Should().Be(HttpStatusCode.NotFound);
                    locationResponse.Locations.Should().BeNullOrEmpty();
                }
            });
        }
示例#3
0
        public async Task <IEnumerable <Station> > GetNearestStations()
        {
            ILocationResponse location = await _locationProvider.GetPositionAsync();

            return(location is GeoLocation
                ? await GetNearestStationsTo(location as GeoLocation)
                : Enumerable.Empty <Station>());
        }
示例#4
0
 public LocationController(ISpotUser user, ILocation location, IAtomicLocationWork atomicWork,
                           ILocationResponse response, ILocationFacade locationFacade)
 {
     _user           = user;
     _location       = location;
     _atomicWork     = atomicWork;
     _response       = response;
     _locationFacade = locationFacade;
 }
示例#5
0
        private async Task AddLocationToIssue(ReportedIssue issue)
        {
            ILocationResponse location = await _locationProvider.GetPositionAsync();

            if (location is GeoLocation)
            {
                var geoLocation = location as GeoLocation;

                issue.Latitude  = geoLocation.Latitude;
                issue.Longitude = geoLocation.Longitude;
            }
        }