public void TestReplayer()
        {
            var recorder = new MockRecorder();
            var replayer = new MockReplayer();

            #region Time: 0-100ms

            var obj1 = recorder.AddActor(0, f =>
            {
                f.AddInt16(1, 10);
                f.AddInt32(2, -10);
                f.AddFloat(3, 5.7f);
            });

            var var1 = obj1.GetVariable <short>(1);
            var var2 = obj1.GetVariable <int>(2);
            var var3 = obj1.GetVariable <float>(3);

            recorder.AddLine(var1, 0, 100, (short)30);
            recorder.AddStep(var2, 0, 110, 10);
            recorder.AddLine(var3, 0, 90, 9.3f);

            var data = recorder.Record(100);
            Assert.AreEqual(0, data.StartTime);
            Assert.AreEqual(100, data.EndTime);

            replayer.Replay(data.StartTime, data.EndTime, data);

            var mObj1 = replayer.GetActor(1);
            Assert.AreEqual(obj1.StartTime, mObj1.StartTime);
            Assert.AreEqual(obj1.EndTime, mObj1.EndTime);

            var mVar1 = mObj1.GetVariable <short>(1);
            Assert.AreEqual(10, mVar1.GetValue(0));
            Assert.AreEqual(20, mVar1.GetValue(50));
            Assert.AreEqual(30, mVar1.GetValue(100));

            var mVar2 = mObj1.GetVariable <int>(2);
            Assert.AreEqual(-10, mVar2.GetValue(50));

            var mVar3 = mObj1.GetVariable <float>(3);
            Assert.AreEqual(7.7f, mVar3.GetValue(50));
            Assert.AreEqual(9.3f, mVar3.GetValue(95));

            #endregion

            #region Time: 100-200ms

            recorder.AddLine(var1, 110, 150, (short)40);

            #endregion
        }
Beispiel #2
0
        public void TestReplayer()
        {
            var recorder = new MockRecorder();
            var replayer = new MockReplayer();

            #region Time: 0-100ms

            var obj1 = recorder.AddActor(0, f =>
            {
                f.AddInt16(1, 10);
                f.AddInt32(2, -10);
                f.AddFloat(3, 5.7f);
            });

            var var1 = obj1.GetVariable<short>(1);
            var var2 = obj1.GetVariable<int>(2);
            var var3 = obj1.GetVariable<float>(3);

            recorder.AddLine(var1, 0, 100, (short)30);
            recorder.AddStep(var2, 0, 110, 10);
            recorder.AddLine(var3, 0, 90, 9.3f);

            var data = recorder.Record(100);
            Assert.AreEqual(0, data.StartTime);
            Assert.AreEqual(100, data.EndTime);

            replayer.Replay(data.StartTime, data.EndTime, data);

            var mObj1 = replayer.GetActor(1);
            Assert.AreEqual(obj1.StartTime, mObj1.StartTime);
            Assert.AreEqual(obj1.EndTime, mObj1.EndTime);

            var mVar1 = mObj1.GetVariable<short>(1);
            Assert.AreEqual(10, mVar1.GetValue(0));
            Assert.AreEqual(20, mVar1.GetValue(50));
            Assert.AreEqual(30, mVar1.GetValue(100));

            var mVar2 = mObj1.GetVariable<int>(2);
            Assert.AreEqual(-10, mVar2.GetValue(50));

            var mVar3 = mObj1.GetVariable<float>(3);
            Assert.AreEqual(7.7f, mVar3.GetValue(50));
            Assert.AreEqual(9.3f, mVar3.GetValue(95));

            #endregion

            #region Time: 100-200ms

            recorder.AddLine(var1, 110, 150, (short)40);

            #endregion
        }
        public void TestMockConsistency()
        {
            var random   = new Random();
            var recorder = new MockRecorder();
            var replayer = new MockReplayer();

            for (var time = 0; time < TotalRunTime; time += RecordInterval)
            {
                var data = RandomRecord(random, recorder, time);

                replayer.Replay(time, time + RecordInterval, data);

                for (var frameTime = time; frameTime < time + RecordInterval; frameTime += ReplayInterval)
                {
                    var recorderFrame = GetFrameData(recorder.Scene, frameTime);
                    var replayerFrame = GetFrameData(replayer.Scene, frameTime);

                    CompareFrameData(recorderFrame, replayerFrame);
                }
            }
        }