本文整理汇总了C#中Plane.ToJson方法的典型用法代码示例。如果您正苦于以下问题:C# Plane.ToJson方法的具体用法?C# Plane.ToJson怎么用?C# Plane.ToJson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plane
的用法示例。
在下文中一共展示了Plane.ToJson方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestPlaneToJson
public static void TestPlaneToJson()
{
//The one thing we want to check
// -a valid plane object converts to a valid JSON object
//We could do some tests here as far as malformed/invalid objects, but that ObjectTests should probably be ensuring we are getting a proper object
//make some planes
Plane plane1 = new Plane("abcd", new PlaneAttributes("abcd", 2, 45, 20, 100, 19000)); //valid plane object
Plane plane2 = new Plane("DEF328", new PlaneAttributes("483CBA50", 1, 35, 15, 50, 12000)); //valid plane object
//Give them a current position - AddPosition(GPSData data)
GPSData gps1 = new GPSData (-90, 90, 20000, 232050);
GPSData gps2 = new GPSData (-45, 45, 15000, 190000);
plane1.AddPosition(gps1);
plane2.AddPosition(gps2);
//convert the objects to JSON
string jsonPlane1 = plane1.ToJson();
string jsonPlane2 = plane2.ToJson();
JsonObject correctJSONObject1 = (JsonObject)Json.Parse(createCorrectDataSet());
JsonObject correctJSONObject2 = (JsonObject)Json.Parse(createCorrectDataSet2());
//test them
jsonPlane1.ShouldBe(correctJSONObject1.PrettyPrint());
jsonPlane2.ShouldBe(correctJSONObject2.PrettyPrint());
}