public void LevelStart(int level, int millisecondsOffset = 0) { DoAfterUpdate(() => { var realTime = _speedrunStopwatch.RealTime + TimeSpan.FromMilliseconds(millisecondsOffset); var gameTime = _beatTimer.Time.AddOffset(millisecondsOffset); var time = new SpeedrunTime(realTime, gameTime); RunLog.LevelStart(level, time); }); }
public void AllLevels() { var log = new RunLog(); var timeIncrement = new SpeedrunTime(TimeSpan.FromMinutes(3.1374), TimeSpan.FromMinutes(2.7684)); var timer = new SpeedrunTime(); for (var lvl = 1; lvl <= log.Levels.Length; lvl++) { timer += timeIncrement; log.LevelStart(lvl, timer); var expectedLevelTime = new SpeedrunTime(); for (var i = 0; i < lvl; i++) { timer += timeIncrement; expectedLevelTime += timeIncrement; } log.CompleteLevel(lvl, timer); Assert.AreEqual(expectedLevelTime, log.Levels[lvl - 1].Time); Assert.AreEqual(timer, log.Levels[lvl - 1].SplitTime); } }