public void TestFwCore () { var fwCore = new FwCore (); fwCore.Location = new Location (52.365299224853516, 9.6899404525756836); fwCore.Category = "restaurant"; var source = new Source (); source.Name = "OpenStreetMap"; source.WebSite = @"http://www.openstreetmap.org"; source.Licence = @"http://www.openstreetmap.org/copyright"; fwCore.Source = source; fwCore.Name = "Mi Pueblito"; fwCore.Description = "no steps, to wheelchair toilets"; fwCore.LastUpdate = new LastUpdate ("x", 1234); string jsonLocationString = @"""location"":{""wgs84"":{""latitude"":52.365299224853516,""longitude"":9.6899404525756836}}"; string jsonLastUpdateString = @"""last_update"":{""timestamp"":1234,""responsible"":""x""}"; string jsonNameString = @"""name"":{"""":""Mi Pueblito""}"; string jsonDescrString = @"""description"":{"""":""no steps, to wheelchair toilets""}"; string jsonCatString = @"""category"":""restaurant"""; string jsonSourceString = @"""source"":{""name"":""OpenStreetMap"",""website"":""http://www.openstreetmap.org"",""license"":""http://www.openstreetmap.org/copyright""}"; string jsonFwCore = string.Format ("{0},{1},{2},{3},{4},{5}", jsonLocationString, jsonSourceString, jsonNameString, jsonCatString, jsonDescrString, jsonLastUpdateString); jsonFwCore = "{" + jsonFwCore + "}"; var fwCoreObject = MiniJSON.Json.Deserialize (jsonFwCore); var fwCoreDeserialized = new FwCore (fwCoreObject); Assert.AreEqual (fwCoreDeserialized, fwCore); var fwCoreSerialized = fwCore.ToDictionary (); var fwCoreJsonSerialized = MiniJSON.Json.Serialize (fwCoreSerialized); Assert.AreEqual (jsonFwCore, fwCoreJsonSerialized); }
public void TestPoIInfo () { var fwCore = new FwCore (); fwCore.Location = new Location (52.365299224853516, 9.6899404525756836); fwCore.Category = "restaurant"; // var source = new Source (); // source.Name = "OpenStreetMap"; // source.WebSite = @"http://www.openstreetmap.org"; // source.Licence = @"http://www.openstreetmap.org/copyright"; // fwCore.Source = source; fwCore.Name = "Mi Pueblito"; fwCore.Description = "no steps, to wheelchair toilets"; fwCore.LastUpdate = new LastUpdate ("x", 1234); PoIInfo pInfo = new PoIInfo ("asdb-asdf-asdf-asdf"); pInfo.FwCore = fwCore; string jsonLocationString = @"""location"":{""wgs84"":{""latitude"":52.365299224853516,""longitude"":9.6899404525756836}}"; string jsonLastUpdateString = @"""last_update"":{""timestamp"":1234,""responsible"":""x""}"; string jsonNameString = @"""name"":{"""":""Mi Pueblito""}"; string jsonDescrString = @"""description"":{"""":""no steps, to wheelchair toilets""}"; string jsonCatString = @"""category"":""restaurant"""; //string jsonSourceString = @"""source"":{""name"":""OpenStreetMap"",""website"":""http://www.openstreetmap.org"",""license"":""http://www.openstreetmap.org/copyright""}"; string jsonFwCore = string.Format ("{0},{1},{2},{3},{4}", jsonLocationString, jsonNameString, jsonCatString, jsonDescrString, jsonLastUpdateString); string jsonPoi = @"{""asdb-asdf-asdf-asdf"":{""fw_core"":{" + jsonFwCore + "}}}"; //string jsonPoiUpdate = @"{""asdb-asdf-asdf-asdf"":{""fw_core"":{" + jsonFwCore + @"},""fw_time"":{""type"":""open""}}}"; var poiObject = MiniJSON.Json.Deserialize (jsonPoi) as System.Collections.Generic.Dictionary<string, object>; foreach (var k in poiObject) { var poiDeserialized = new PoIInfo (k); Assert.AreEqual (poiDeserialized, pInfo); } var poiSerialized = pInfo.ToDictionary (true); var poiJsonSerialized = MiniJSON.Json.Serialize (poiSerialized); Assert.AreEqual (jsonPoi, poiJsonSerialized); }
public void TestAddDelete () { PoIInterface pInterface = new PoIInterface (POI_DP_URL); PoIInfo pInfo = new PoIInfo (); FwCore fwCore = new FwCore (); fwCore.Name = "asd"; fwCore.Category = "restaurant"; fwCore.Location = new Location (0.345, 0.66577); fwCore.Source = new Source ("OpenStreetMap", @"http://www.openstreetmap.org", @"http://www.openstreetmap.org/copyright"); pInfo.FwCore = fwCore; pInfo.FwTime = FwTime.Open; pInfo = pInterface.Add (pInfo); Console.WriteLine (pInfo.Id); Assert.IsNotNullOrEmpty (pInfo.Id); bool retDelete = pInterface.Delete (pInfo); Assert.IsTrue (retDelete); }