Exemplo n.º 1
0
 public void SetUp()
 {
     handler = new TestInputHandler(replay = new Replay
     {
         HasReceivedAllFrames = false
     });
 }
Exemplo n.º 2
0
        public void TestReplayFramesSortStability()
        {
            const double repeating_time = 5000;

            // add a collection of frames in shuffled order time-wise; each frame also stores its original index to check stability later.
            // data is hand-picked and breaks if the unstable List<T>.Sort() is used.
            // in theory this can still return a false-positive with another unstable algorithm if extremely unlucky,
            // but there is no conceivable fool-proof way to prevent that anyways.
            replay.Frames.AddRange(new[]
            {
                repeating_time,
                0,
                3000,
                repeating_time,
                repeating_time,
                6000,
                9000,
                repeating_time,
                repeating_time,
                1000,
                11000,
                21000,
                4000,
                repeating_time,
                repeating_time,
                8000,
                2000,
                7000,
                repeating_time,
                repeating_time,
                10000
            }.Select((time, index) => new TestReplayFrame(time, true, index)));

            replay.HasReceivedAllFrames = true;

            // create a new handler with the replay for the sort to be performed.
            handler = new TestInputHandler(replay);

            // ensure sort stability by checking that the frames with time == repeating_time are sorted in ascending frame index order themselves.
            var repeatingTimeFramesData = replay.Frames
                                          .Cast <TestReplayFrame>()
                                          .Where(f => f.Time == repeating_time)
                                          .Select(f => f.FrameIndex);

            Assert.That(repeatingTimeFramesData, Is.Ordered.Ascending);
        }
 public void SetUp()
 {
     handler = new TestInputHandler(replay = new Replay
     {
         Frames = new List <ReplayFrame>
         {
             new TestReplayFrame(0),
             new TestReplayFrame(1000),
             new TestReplayFrame(2000),
             new TestReplayFrame(3000, true),
             new TestReplayFrame(4000, true),
             new TestReplayFrame(5000, true),
             new TestReplayFrame(7000, true),
             new TestReplayFrame(8000),
         }
     });
 }