public void 登録済国コード取得API() { var json = new StreamReader("CountryList.json").ReadToEnd(); var list = JsonConvert.DeserializeObject<List<Country>>(json).Select(x => x.CountryCode); var apiResult = new ApiClient().CountryListAsync().Result; Assert.IsTrue(list.SequenceEqual(apiResult)); }
public void 直近AED位置情報取得API() { var json = new StreamReader("NearAED_lat=35.96&lng=136.185.json").ReadToEnd(); var list = JsonConvert.DeserializeObject<List<AedInfo>>(json); var apiResult = new ApiClient().NearAedAsync(35.96, 136.185).Result; Assert.IsTrue(list.SequenceEqual(apiResult)); }
public void 市町村区単位での登録件数API() { var json = new StreamReader("aedgroup.json").ReadToEnd(); var list = JsonConvert.DeserializeObject<List<City>>(json); var apiResult = new ApiClient().AedGroupAsync().Result; Assert.IsTrue(list.SequenceEqual(apiResult)); }
public void 市町村区単位でのAED位置情報取得API() { var json = new StreamReader("aedinfo_福井県_鯖江市.json").ReadToEnd(); var list = JsonConvert.DeserializeObject<List<AedInfo>>(json); var apiResult = new ApiClient().AedInfoAsync("福井県", "鯖江市").Result; Assert.IsTrue(list.SequenceEqual(apiResult)); }
public void 国コード指定都道府県一覧取得API() { var json = new StreamReader("PerfectureList_jp.json").ReadToEnd(); var list = JsonConvert.DeserializeObject<List<Perfecture>>(json); var apiResult = new ApiClient().PerfectureListAsync("jp").Result; Assert.IsTrue(list.SequenceEqual(apiResult)); }
public void 周辺AED位置情報取得API() { var json = new StreamReader("AEDSearch_lat=35.96&lng=136.185&r=300.json").ReadToEnd(); var list = JsonConvert.DeserializeObject<List<AedInfo>>(json); var apiResult = new ApiClient().AedSearchAsync(35.96, 136.185, 300).Result; Assert.IsTrue(list.SequenceEqual(apiResult)); }
public void AED位置情報取得API() { var json = new StreamReader("id_2907.json").ReadToEnd(); var list = JsonConvert.DeserializeObject<List<AedInfo>>(json); var apiResult = new ApiClient().IdAsync(2907).Result; Assert.IsTrue(list.SequenceEqual(apiResult)); }
public async Task UpdateNearAeds() { if(IsUpdating.Value) return; if(UserLocation.Value == null) { Device.BeginInvokeOnMainThread(() => SendSearchNearAedsFailed("UserLocationMissingMessage")); return; } IsUpdating.Value = true; var radius = Settings.RegionRadius; var position = UserLocation.Value.Value; Task<List<AedInfo>> nearestAedTask; Task<List<AedInfo>> nearAedsTask; try { using(nearestAedTask = new ApiClient().NearAedAsync(position.Latitude, position.Longitude)) using(nearAedsTask = new ApiClient().AedSearchAsync(position.Latitude, position.Longitude, (int)(radius * 1.2))) { await Task.WhenAll(nearestAedTask, nearAedsTask).ConfigureAwait(false); } } catch(Exception exception) { IsUpdating.Value = false; Console.WriteLine(exception); Device.BeginInvokeOnMainThread(() => SendSearchNearAedsFailed("AedApiRequestFailedMessage")); return; } if(nearAedsTask.Result.Count == 0 && nearestAedTask.Result.First().Distance > Settings.MaxRadius) { IsUpdating.Value = false; Device.BeginInvokeOnMainThread(() => SendSearchNearAedsFailed("AedNotFoundMessage")); return; } var newAeds = nearestAedTask.Result .Concat(nearAedsTask.Result) .GroupBy(aed => aed.Id) .Select(group => new AedViewModel(group.First())) .ToList(); Device.BeginInvokeOnMainThread(() => { AedsViewModel.Value.Aeds = newAeds; }); IsUpdating.Value = false; }