コード例 #1
0
    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());
    }
コード例 #2
0
    //Method for Initializing an array of planes for testing
    public static Plane[][] createTestSet()
    {
        //TBD: Add some plane data for 'successful' collisions tests here
        //The test data needs to be pretty precise (down to the .001 lat/long and a number of entries over a few seconds)
        PlaneAttributes atts = new PlaneAttributes("default", 1, 150, 150, 150, 3000);
        long zeroTime = 0x7000000010000000;
        double denverLat = 39.7392;
        double denverLong = 104.9903;

        double sydneyLat = -33.8830555556;
        double sydneyLong = 151.216666667;

        double moscowLat = 55.7522222;
        double moscowLong = 37.6155556;

        //head on collision
        Plane a = new Plane("a", atts);
        Plane aa = new Plane("aa", atts);

        for (int i = 0; i < 100; i++) {
            a.AddPosition(new GPSData(denverLat, denverLong + .0223 - i * .0001, 2000, zeroTime + 1000 * i));
            aa.AddPosition(new GPSData(denverLat, denverLong - .0223 + i * .0001, 2000, zeroTime + 1000 * i));
        }

        Console.WriteLine(a.GetPosition() + " : " +  a.GetVelocity());
        Console.WriteLine(aa.GetPosition() + " : " +  aa.GetVelocity());

        //right angle collision
        Plane b = new Plane("b", atts);
        Plane bb = new Plane("bb", atts);

        for (int i = 0; i < 100; i++) {
            b.AddPosition(new GPSData(sydneyLat - .0223 + i * .0001, sydneyLong, 2000, zeroTime + 1000 * i));
            bb.AddPosition(new GPSData(sydneyLat, sydneyLong - .0223 + i * .0001, 2000, zeroTime + 1000 * i));
        }

        //Collision from behind
        Plane c = new Plane("c", atts);
        Plane cc = new Plane("cc", atts);

        for (int i = 0; i < 100; i++) {
            c.AddPosition(new GPSData(moscowLat, moscowLong - .0200 + i * .0002, 2000, zeroTime + 1000 * i));
            cc.AddPosition(new GPSData(moscowLat, moscowLong - .0400 + i * .00035, 2000, zeroTime + 1000 * i));
        }

        Plane[][] planeArray = new Plane[][] {
            new Plane[] { a, aa },
            new Plane[] { b, bb },
            new Plane[] { c, cc }
        };

        return planeArray;
    }
コード例 #3
0
    //Method for initializing an array of planes for fail tests
    private static Plane[][] createFailTestSet()
    {
        //Add some plane data for fail tests here
        //The test data needs to be pretty precise (down to the .001 lat/long and a number of entries over a few seconds)
        PlaneAttributes atts = new PlaneAttributes("default", 1, 150, 150, 150, 3000);
        long zeroTime = 0x7000000010000000;
        double denverLat = 39.7392;
        double denverLong = 104.9903;

        Plane a = new Plane("a", atts);
        Plane aa = new Plane("aa", atts);
        Plane b = new Plane("b", atts);
        Plane bb = new Plane("bb", atts);
        Plane c = new Plane("c", atts);
        Plane cc = new Plane("cc", atts);

        for (int i = 0; i < 100; i++) {
            //Running somewhat parralel on different latitudes
            a.AddPosition(new GPSData(denverLat+.0050, denverLong + .0223 + i * .0001, 2000, zeroTime + 1000 * i));
            aa.AddPosition(new GPSData(denverLat, denverLong + .0213 + i * .0001, 2000, zeroTime + 1000 * i));

            //Running parralel on same latitude and different altitudes
            b.AddPosition(new GPSData(denverLat, denverLong + .0223 + i * .0001, 2500, zeroTime + 1000 * i));
            bb.AddPosition(new GPSData(denverLat, denverLong + .0223 + i * .0001, 2000, zeroTime + 1000 * i));

            //cross at different times
            c.AddPosition(new GPSData(denverLat + i * .0001, denverLong + .0213 + i * .0001, 2500, zeroTime + 1000 * i));
            cc.AddPosition(new GPSData(denverLat + i * .0001, denverLong + .0223 - i * .0001, 2000, zeroTime + 1000 * i));
        }

        Plane[][] failPlaneArray = new Plane[][] {
            new Plane[] { a, aa },
            new Plane[] { b, bb },
            new Plane[] { c, cc }
        };

        return failPlaneArray;
    }