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); }
// End game, stop animations, sounds. Finish recording metrics void EndGame() { pMetric.finishRecording(); lvMetric.finishRecording(); var str = metricWriter.GetLogMetrics( DateTime.Now, new List <AbstractMetric>() { pMetric, lvMetric } ); StartCoroutine(Post("rockstar_" + DateTime.Now.ToFileTime() + ".json", str)); EndLevel(0f); rockstar.enabled = false; spotlight.enabled = false; meter.enabled = false; background.speed = 0f; music.Stop(); }
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()); }