static private ParseIntoLocation ( byte jsonBytes ) : GlobalLocation | ||
jsonBytes | byte | |
return | GlobalLocation |
public void ParseInLocation_PlanetTest() { var json = @"{ ""meta"": { ""code"": 200 }, ""response"": { ""checkin"": { ""id"": ""xxxxxxxxx"", ""type"": ""checkin"", ""venue"": { ""id"": ""5069d8bdc640385aa7711fe4"", ""name"": ""Gale Crater"", ""location"": { ""planet"": ""mars"", ""lat"": 34.201694, ""lng"": -118.17166 } } } } }"; var jsonBytes = Encoding.UTF8.GetBytes(json); var location = FoursquareCheckin.ParseIntoLocation(jsonBytes); // 地球以外の位置にあるベニューに対しては null を返す Assert.Null(location); }
public void ParseInLocation_CultureTest() { var json = @"{ ""meta"": { ""code"": 200 }, ""response"": { ""checkin"": { ""id"": ""xxxxxxxxx"", ""type"": ""checkin"", ""venue"": { ""id"": ""4b73dedcf964a5206bbe2de3"", ""name"": ""高松駅 (Takamatsu Sta.)"", ""location"": { ""lat"": 34.35067978344854, ""lng"": 134.04693603515625 } } } } }"; var origCulture = Thread.CurrentThread.CurrentCulture; Thread.CurrentThread.CurrentCulture = new CultureInfo("ru-RU"); var jsonBytes = Encoding.UTF8.GetBytes(json); var location = FoursquareCheckin.ParseIntoLocation(jsonBytes); Thread.CurrentThread.CurrentCulture = origCulture; Assert.NotNull(location); Assert.Equal(34.35067978344854, location.Latitude); Assert.Equal(134.04693603515625, location.Longitude); }
public void ParseInLocation_VenueNullTest() { var json = @"{ ""meta"": { ""code"": 200 }, ""response"": { ""checkin"": { ""id"": ""xxxxxxxxx"", ""type"": ""checkin"", ""venue"": null } } }"; var jsonBytes = Encoding.UTF8.GetBytes(json); var location = FoursquareCheckin.ParseIntoLocation(jsonBytes); // ベニュー情報が得られなかった場合は null を返す Assert.Null(location); }