public void GetGeocoding_傳入地標_回傳地理編碼資料() { // arrange // 模擬 proxy 吐出的資料 var response = new Infrastructure.ClassLibsProxy.Models.GoogleResponse { AllResponse = "{\"Method\":\"Geocoding\",\"OtherParams\":{\"QueryAddress\":\"台北101\",\"FixingAddress\":\"台北101\",\"GeoKey\":\"EEPS_AP_Geocoder\",\"Channel\":\"EEPS_AP_Geocoder\",\"APIUrl\":\"http://maps.google.com/maps/api/geocode/json?components=country%3atw\\u0026address=%e5%8f%b0%e5%8c%97101\\u0026sensor=false\\u0026language=zh-tw\\u0026region=tw\"},\"Locate\":{\"GqId\":3,\"GeoId\":81259,\"City\":\"台北市\",\"Area\":\"信義區\",\"Road\":\"\",\"No\":\"\",\"Address\":\"110台灣台北市信義區台北101大樓\",\"Lat\":25.0339639,\"Lng\":121.5644722,\"LocationType\":\"ROOFTOP\",\"PoiName\":\"\",\"PoiTypes\":\"premise\"},\"Success\":true,\"Status\":1,\"Message\":\"查詢成功\",\"Precise\":false,\"GeoSource\":\"Database\"}", ErrorMessage = string.Empty, QueryAddress = "台北101", QueryLatitude = 0, QueryLongitude = 0, Locate = new Infrastructure.ClassLibsProxy.Models.GoogleLocate { Address = "110台灣台北市信義區台北101大樓", Area = "信義區", City = "台北市", Landmark = string.Empty, Latitude = 25.0339639, Longitude = 121.5644722, PreciseLevel = true, Road = string.Empty }, Status = Infrastructure.Enums.GoogleLocateStatus.Success }; this.GisProxy.GetGeocoding(Arg.Any<DTOs.GeoLocationParameterDto>()) .Returns(response); // 預期 service 吐出的資料 var expected = new DTOs.GoogleGeoDataDto { AllResponse = "{\"Method\":\"Geocoding\",\"OtherParams\":{\"QueryAddress\":\"台北101\",\"FixingAddress\":\"台北101\",\"GeoKey\":\"EEPS_AP_Geocoder\",\"Channel\":\"EEPS_AP_Geocoder\",\"APIUrl\":\"http://maps.google.com/maps/api/geocode/json?components=country%3atw\\u0026address=%e5%8f%b0%e5%8c%97101\\u0026sensor=false\\u0026language=zh-tw\\u0026region=tw\"},\"Locate\":{\"GqId\":3,\"GeoId\":81259,\"City\":\"台北市\",\"Area\":\"信義區\",\"Road\":\"\",\"No\":\"\",\"Address\":\"110台灣台北市信義區台北101大樓\",\"Lat\":25.0339639,\"Lng\":121.5644722,\"LocationType\":\"ROOFTOP\",\"PoiName\":\"\",\"PoiTypes\":\"premise\"},\"Success\":true,\"Status\":1,\"Message\":\"查詢成功\",\"Precise\":false,\"GeoSource\":\"Database\"}", ErrorMessage = string.Empty, QueryAddress = "台北101", QueryLatitude = 0, QueryLongitude = 0, Locate = new DTOs.GoogleLocateDto { Address = "110台灣台北市信義區台北101大樓", District = "信義區", County = "台北市", Landmark = string.Empty, Latitude = 25.0339639, Longitude = 121.5644722, IsPrecise = true, Road = string.Empty }, Status = Infrastructure.Enums.GoogleLocateStatus.Success }; var sut = new GoogleGisService(this.GisProxy); // act var actual = sut.GetGeocoding(Arg.Any<DTOs.GeoLocationParameterDto>()); // assert // 透過 ExpectedObjects 第三方套件的功能比對物件. expected.ToExpectedObject().ShouldEqual(actual); }
public void GetGeocoding_傳入地址_回傳地理編碼資料() { // arrange // 模擬 proxy 吐出的資料 var response = new Infrastructure.ClassLibsProxy.Models.GoogleResponse { AllResponse = "{\"Method\":\"Geocoding\",\"OtherParams\":{\"QueryAddress\":\"台北市大安區敦化南路二段77號\",\"FixingAddress\":\"臺北市大安區敦化南路二段77號\",\"GeoKey\":\"EEPS_AP_Geocoder\",\"Channel\":\"EEPS_AP_Geocoder\",\"APIUrl\":\"http://maps.google.com/maps/api/geocode/json?components=country%3atw\\u0026address=%e8%87%ba%e5%8c%97%e5%b8%82%e5%a4%a7%e5%ae%89%e5%8d%80%e6%95%a6%e5%8c%96%e5%8d%97%e8%b7%af%e4%ba%8c%e6%ae%b577%e8%99%9f\\u0026sensor=false\\u0026language=zh-tw\\u0026region=tw\"},\"Locate\":{\"GqId\":1,\"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 = "台北市大安區敦化南路二段77號", QueryLatitude = 0, QueryLongitude = 0, Locate = new Infrastructure.ClassLibsProxy.Models.GoogleLocate { Address = "106台灣台北市大安區敦化南路二段77號", Area = "大安區", City = "台北市", Landmark = string.Empty, Latitude = 25.030284, Longitude = 121.549201, PreciseLevel = true, Road = "敦化南路二段" }, Status = Infrastructure.Enums.GoogleLocateStatus.Success }; this.GisProxy.GetGeocoding(Arg.Any<DTOs.GeoLocationParameterDto>()) .Returns(response); // 預期 service 吐出的資料 var expected = new DTOs.GoogleGeoDataDto { AllResponse = "{\"Method\":\"Geocoding\",\"OtherParams\":{\"QueryAddress\":\"台北市大安區敦化南路二段77號\",\"FixingAddress\":\"臺北市大安區敦化南路二段77號\",\"GeoKey\":\"EEPS_AP_Geocoder\",\"Channel\":\"EEPS_AP_Geocoder\",\"APIUrl\":\"http://maps.google.com/maps/api/geocode/json?components=country%3atw\\u0026address=%e8%87%ba%e5%8c%97%e5%b8%82%e5%a4%a7%e5%ae%89%e5%8d%80%e6%95%a6%e5%8c%96%e5%8d%97%e8%b7%af%e4%ba%8c%e6%ae%b577%e8%99%9f\\u0026sensor=false\\u0026language=zh-tw\\u0026region=tw\"},\"Locate\":{\"GqId\":1,\"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 = "台北市大安區敦化南路二段77號", QueryLatitude = 0, QueryLongitude = 0, Locate = new DTOs.GoogleLocateDto { Address = "106台灣台北市大安區敦化南路二段77號", District = "大安區", County = "台北市", Landmark = string.Empty, Latitude = 25.030284, Longitude = 121.549201, IsPrecise = true, Road = "敦化南路二段" }, Status = Infrastructure.Enums.GoogleLocateStatus.Success }; var sut = new GoogleGisService(this.GisProxy); // act var actual = sut.GetGeocoding(Arg.Any<DTOs.GeoLocationParameterDto>()); // assert // 透過 ExpectedObjects 第三方套件的功能比對物件. expected.ToExpectedObject().ShouldEqual(actual); }
public void GetGeocoding_傳入地址_找不到資料_回傳預設GoogleGeoDataDto() { // arrange // 模擬 proxy 吐出的資料 var response = new Infrastructure.ClassLibsProxy.Models.GoogleResponse(); response.Status = Infrastructure.Enums.GoogleLocateStatus.ZeroResult; this.GisProxy.GetGeocoding(Arg.Any<DTOs.GeoLocationParameterDto>()) .Returns(response); // 預期 service 吐出的資料 var expected = new DTOs.GoogleGeoDataDto(); expected.Status = Infrastructure.Enums.GoogleLocateStatus.ZeroResult; var sut = new GoogleGisService(this.GisProxy); // act var actual = sut.GetGeocoding(Arg.Any<DTOs.GeoLocationParameterDto>()); // assert // 透過 ExpectedObjects 第三方套件的功能比對物件. expected.ToExpectedObject().ShouldEqual(actual); }