Пример #1
0
    public void TestRecordEvent()
    {
        PositionMetric pm1 = new PositionMetric(new List <string> {
            "1", "2"
        });

        pm1.startRecording();
        Assert.IsEmpty(pm1.eventList);
        Assert.IsTrue(pm1.isRecording);

        pm1.recordEvent(null);
        Assert.IsEmpty(pm1.eventList);

        // Test adding events to a PositionMetric which has not started recording
        PositionMetric pm2 = new PositionMetric(new List <string> {
            "1", "2"
        });

        Assert.IsFalse(pm2.isRecording);
        Assert.IsEmpty(pm2.eventList);

        List <Vector2> v1 = new List <Vector2>();

        v1.Add(new Vector2(10, 10));
        v1.Add(new Vector2(0, 0));
        pm2.recordEvent(new PositionEvent(new System.DateTime(2021, 2, 1), v1));
        Assert.IsEmpty(pm2.eventList);
    }
Пример #2
0
    public void TestStartFinishRecording()
    {
        PositionMetric pm = new PositionMetric(new List <string> {
            "1", "2"
        });

        Assert.IsFalse(pm.isRecording);

        pm.startRecording();
        Assert.IsTrue(pm.isRecording);

        pm.finishRecording();
        Assert.IsFalse(pm.isRecording);
    }
Пример #3
0
 // Begin the actual game, start recording metrics
 void StartGame()
 {
     pMetric.startRecording();
     lvMetric.startRecording();
     metricWriter      = new MetricJSONWriter("Rockstar", DateTime.Now, seed); // initialize metric data writer
     gameStartTime     = Time.time;
     rockstar.enabled  = true;
     spotlight.enabled = true;
     meter.enabled     = true;
     if (enableAnimations)
     {
         background.Play("Base Layer.rockstarbg_1");
     }
     if (musicTrack > -1)
     {
         music.clip = tracks[musicTrack - 1];
         music.Play();
     }
 }
Пример #4
0
    public void TestGetJSON()
    {
        // Test getJSON() when metric has no records
        PositionMetric pm1 = new PositionMetric(new List <string> {
            "1", "2"
        });

        Assert.IsEmpty(pm1.eventList);

        JObject json1 = pm1.getJSON();

        Assert.IsNotNull(json1);

        // Test getJSON() with one record
        PositionMetric pm2 = new PositionMetric(new List <string> {
            "1", "2"
        });

        pm2.startRecording();
        Assert.IsTrue(pm2.isRecording);
        Assert.IsEmpty(pm2.eventList);

        List <Vector2> v1 = new List <Vector2>();

        v1.Add(new Vector2(20, 20));
        v1.Add(new Vector2(20, 30));
        pm2.recordEvent(new PositionEvent(new System.DateTime(2021, 2, 1), v1));
        pm2.finishRecording();

        JObject json2 = pm2.getJSON();

        Assert.AreEqual(1, pm2.eventList.Count);
        Assert.IsNotNull(json2);

        JArray json2p = (JArray)json2["eventList"];

        Assert.AreEqual(1, json2p.Count);
        Assert.AreEqual("2021-02-01 12:00:00 AM", json2p[0]["eventTime"].ToString());
    }