public void ReverseGeocoding_傳入經緯度_回傳SuccessOutputModel()
        {
            // arrange
            // 因為是UnitTest所以HttpContext.Current會是null,所以要假造 HttpContext.Current
            HttpContext.Current = GIS.Tests.Helpers.HttpContextHelper.FakeHttpContext();

            // 模擬 service 吐出的資料
            var googleGeoDataDto = new Service.DTOs.GoogleGeoDataDto
            {
                AllResponse = "{\"Method\":\"ReverseGeocoding\",\"OtherParams\":{\"QLat\":25.030284,\"QLng\":121.549201,\"GeoKey\":\"EEPS_AP_Geocoder\",\"Channel\":\"EEPS_AP_Geocoder\",\"APIUrl\":\"http://maps.google.com/maps/api/geocode/json?latlng=25.030284%2c121.549201\\u0026sensor=false\\u0026language=zh-tw\\u0026region=tw\"},\"Locate\":{\"GqId\":260,\"GeoId\":4279,\"City\":\"台北市\",\"Area\":\"大安區\",\"Road\":\"敦化南路二段\",\"No\":\"\",\"Address\":\"106台灣台北市大安區敦化南路二段77號\",\"Lat\":25.030284,\"Lng\":121.549201,\"LocationType\":\"ROOFTOP\",\"PoiName\":\"\",\"PoiTypes\":\"street_address\"},\"Success\":true,\"Status\":1,\"Message\":\"查詢成功\",\"Precise\":true,\"GeoSource\":\"Database\"}",
                ErrorMessage = string.Empty,
                QueryAddress = string.Empty,
                QueryLatitude = 25.030284,
                QueryLongitude = 121.549201,
                Locate = new Service.DTOs.GoogleLocateDto
                {
                    Address = "106台灣台北市大安區敦化南路二段77號",
                    District = "大安區",
                    County = "台北市",
                    Landmark = string.Empty,
                    Latitude = 25.030284,
                    Longitude = 121.549201,
                    IsPrecise = true,
                    Road = "敦化南路二段"
                },
                Status = Infrastructure.Enums.GoogleLocateStatus.Success
            };

            this.GoogleGisService.ReverseGeocoding(Arg.Any<Service.DTOs.GeoCodingParameterDto>())
                .Returns(googleGeoDataDto);

            var controller = new GoogleGeoController(this.GoogleGisService)
            {
                Configuration = new HttpConfiguration(),
                Request = new HttpRequestMessage
                {
                    Method = HttpMethod.Get,
                    RequestUri = new Uri("http://localhost/gis/googlegeo/reverse?geokey=EEPS_AP_Geocoder&latitude=25.030284&longitude=121.549201")
                }
            };

            var responseId = new Guid("431C5A69-6464-422E-B79D-8A206069145C");
            controller.ResponseId = responseId;

            var parameter = new Models.ParameterModels.GeoCodingParameter
            {
                GeoKey = "EEPS_AP_Geocoder",
                Latitude = "25.030284",
                Longitude = "121.549201"
            };

            // 預期資料
            var expected = new SuccessOutputModel<Models.OutputModels.GoogleGeoDataViewModel>()
            {
                ApiVersion = "1.0.0",
                Method = "/gis/googlegeo/reverse.GET",
                Data = new Models.OutputModels.GoogleGeoDataViewModel()
                {
                    AllResponse = "{\"Method\":\"ReverseGeocoding\",\"OtherParams\":{\"QLat\":25.030284,\"QLng\":121.549201,\"GeoKey\":\"EEPS_AP_Geocoder\",\"Channel\":\"EEPS_AP_Geocoder\",\"APIUrl\":\"http://maps.google.com/maps/api/geocode/json?latlng=25.030284%2c121.549201\\u0026sensor=false\\u0026language=zh-tw\\u0026region=tw\"},\"Locate\":{\"GqId\":260,\"GeoId\":4279,\"City\":\"台北市\",\"Area\":\"大安區\",\"Road\":\"敦化南路二段\",\"No\":\"\",\"Address\":\"106台灣台北市大安區敦化南路二段77號\",\"Lat\":25.030284,\"Lng\":121.549201,\"LocationType\":\"ROOFTOP\",\"PoiName\":\"\",\"PoiTypes\":\"street_address\"},\"Success\":true,\"Status\":1,\"Message\":\"查詢成功\",\"Precise\":true,\"GeoSource\":\"Database\"}",
                    ErrorMessage = string.Empty,
                    QueryAddress = string.Empty,
                    QueryLatitude = 25.030284,
                    QueryLongitude = 121.549201,
                    Locate = new Models.OutputModels.GoogleLocateViewModel()
                    {
                        Address = "106台灣台北市大安區敦化南路二段77號",
                        District = "大安區",
                        County = "台北市",
                        Landmark = string.Empty,
                        Latitude = 25.030284,
                        Longitude = 121.549201,
                        IsPrecise = true,
                        Road = "敦化南路二段"
                    },
                    Status = Infrastructure.Enums.GoogleLocateStatus.Success
                },
                Id = responseId
            };

            // act
            HttpResponseMessage actual = controller.ReverseGeocoding(parameter);

            SuccessOutputModel<Models.OutputModels.GoogleGeoDataViewModel> actualResultModel;
            actual.TryGetContentValue(out actualResultModel).Should().BeTrue();

            // assert
            actualResultModel.ToExpectedObject().ShouldEqual(expected);
        }
        public void ReverseGeocoding_傳入經緯度_找不到資料_回傳預設SuccessOutputModel()
        {
            // arrange
            // 因為是UnitTest所以HttpContext.Current會是null,所以要假造 HttpContext.Current
            HttpContext.Current = GIS.Tests.Helpers.HttpContextHelper.FakeHttpContext();

            // 模擬 service 吐出的資料
            var googleGeoDataDto = new Service.DTOs.GoogleGeoDataDto();
            googleGeoDataDto.Status = Infrastructure.Enums.GoogleLocateStatus.ZeroResult;

            this.GoogleGisService.ReverseGeocoding(Arg.Any<Service.DTOs.GeoCodingParameterDto>())
                .Returns(googleGeoDataDto);

            var controller = new GoogleGeoController(this.GoogleGisService)
            {
                Configuration = new HttpConfiguration(),
                Request = new HttpRequestMessage
                {
                    Method = HttpMethod.Get,
                    RequestUri = new Uri("http://localhost/gis/googlegeo/reverse?geokey=EEPS_AP_Geocoder&latitude=9925.030284&longitude=19921.549201")
                }
            };

            var responseId = new Guid("431C5A69-6464-422E-B79D-8A206069145C");
            controller.ResponseId = responseId;

            var parameter = new Models.ParameterModels.GeoCodingParameter
            {
                GeoKey = "EEPS_AP_Geocoder",
                Latitude = "9925.030284",
                Longitude = "19921.549201"
            };

            // 預期資料
            var expected = new SuccessOutputModel<Models.OutputModels.GoogleGeoDataViewModel>()
            {
                ApiVersion = "1.0.0",
                Method = "/gis/googlegeo/reverse.GET",
                Data = new Models.OutputModels.GoogleGeoDataViewModel()
                {
                    AllResponse = null,
                    ErrorMessage = null,
                    QueryAddress = null,
                    QueryLatitude = 0,
                    QueryLongitude = 0,
                    Locate = null,
                    Status = Infrastructure.Enums.GoogleLocateStatus.ZeroResult
                },
                Id = responseId
            };

            // act
            HttpResponseMessage actual = controller.ReverseGeocoding(parameter);

            SuccessOutputModel<Models.OutputModels.GoogleGeoDataViewModel> actualResultModel;
            actual.TryGetContentValue(out actualResultModel).Should().BeTrue();

            // assert
            actualResultModel.ToExpectedObject().ShouldEqual(expected);
        }
        public void ReverseGeocoding_傳入空白參數_回傳FailOutputModel()
        {
            // arrange
            // 因為是UnitTest所以HttpContext.Current會是null,所以要假造 HttpContext.Current
            HttpContext.Current = GIS.Tests.Helpers.HttpContextHelper.FakeHttpContext();

            var controller = new GoogleGeoController(this.GoogleGisService)
            {
                Configuration = new HttpConfiguration(),
                Request = new HttpRequestMessage
                {
                    Method = HttpMethod.Get,
                    RequestUri = new Uri("http://localhost/gis/googlegeo/reverse?geokey=&latitude=&longitude=")
                }
            };

            var responseId = new Guid("431C5A69-6464-422E-B79D-8A206069145C");
            controller.ResponseId = responseId;

            var parameter = new Models.ParameterModels.GeoCodingParameter
            {
                GeoKey = string.Empty,
                Latitude = string.Empty,
                Longitude = string.Empty
            };

            // act
            Action action = () => controller.ReverseGeocoding(parameter);

            // assert
            action.ShouldThrow<FluentValidation.ValidationException>();
        }