Ejemplo n.º 1
0
        public void FromTick()
        {
            int      numberOfTicks = 4;
            int      minutes       = GameTick.MinutesPerTick * numberOfTicks;
            DateTime newDate       = _time.AddMinutes(minutes);
            GameTick newTick       = GameTick.FromTickNumber(numberOfTicks);

            Assert.AreEqual(_tick.GetTick() + numberOfTicks, newTick.GetTick());
            Assert.AreEqual(newDate.ToLongTimeString(), newTick.GetDate().ToLongTimeString());
            Assert.AreEqual(newDate.ToLongDateString(), newTick.GetDate().ToLongDateString());
        }
Ejemplo n.º 2
0
        public void FromTick()
        {
            int      numberOfTicks = 4;
            double   minutes       = GameTick.MINUTES_PER_TICK * numberOfTicks;
            DateTime newDate       = _time.AddMinutes(minutes);
            GameTick newTick       = new GameTick(numberOfTicks);

            Assert.AreEqual(_tick.GetTick() + numberOfTicks, newTick.GetTick());
            Assert.AreEqual(newDate.ToLongTimeString(), newTick.GetDate(_time).ToLongTimeString());
            Assert.AreEqual(newDate.ToLongDateString(), newTick.GetDate(_time).ToLongDateString());
        }
Ejemplo n.º 3
0
        public void GetNextTick()
        {
            GameTick nextTick = _tick.GetNextTick();

            Assert.AreEqual(_time.AddMinutes(GameTick.MinutesPerTick), nextTick.GetDate());
            Assert.AreEqual(_tickNumber + 1, nextTick.GetTick());
        }
Ejemplo n.º 4
0
        public void GetNextTick()
        {
            GameTick nextTick = _tick.GetNextTick();

            Assert.AreEqual(_time.AddMinutes(GameTick.MINUTES_PER_TICK), nextTick.GetDate(_time));
            Assert.AreEqual(_tickNumber + 1, nextTick.GetTick());
        }
Ejemplo n.º 5
0
        public void FasterGameSpeed()
        {
            GameTick.MINUTES_PER_TICK = 0.1;
            DateTime start   = _tick.GetDate(_time);
            GameTick forward = _tick.Advance(10);

            Assert.AreEqual(forward.GetDate(_time).ToLongTimeString(), start.AddMinutes(GameTick.MINUTES_PER_TICK * 10).ToLongTimeString());
        }
Ejemplo n.º 6
0
        public void FromDate()
        {
            int      numberOfTicks = 4;
            int      minutes       = GameTick.MinutesPerTick * numberOfTicks;
            DateTime newDate       = _time.AddMinutes(minutes);
            GameTick newTick       = GameTick.FromDate(newDate);

            Assert.AreEqual(_tick.GetTick() + numberOfTicks, newTick.GetTick());
            Assert.AreEqual(newDate, newTick.GetDate());
        }
Ejemplo n.º 7
0
        public void GetPreviousTick()
        {
            // Check cannot go back before the first tick
            GameTick previousTick = _tick.GetPreviousTick();

            Assert.AreEqual(_tick, previousTick);

            // Advance and then come back
            GameTick startingTick = _tick.GetNextTick().GetPreviousTick();

            Assert.AreEqual(_time, startingTick.GetDate());
            Assert.AreEqual(_tickNumber, startingTick.GetTick());
        }
Ejemplo n.º 8
0
        public void Rewind()
        {
            int      ticksToReverse = 10;
            GameTick tenTicksBefore = _tick.Rewind(ticksToReverse);

            // Should not be able to reverse
            Assert.AreEqual(true, tenTicksBefore == _tick);

            // Advance and then go back
            GameTick startingTick = _tick.Advance(ticksToReverse).Rewind(ticksToReverse);

            Assert.AreEqual(_time, startingTick.GetDate());
            Assert.AreEqual(_tickNumber, startingTick.GetTick());
        }
Ejemplo n.º 9
0
        public void Advance()
        {
            // Check advancing N ticks
            int      ticksToAdvance = 10;
            GameTick tenMoreTicks   = _tick.Advance(ticksToAdvance);

            Assert.AreEqual(_time.AddMinutes(GameTick.MinutesPerTick * ticksToAdvance), tenMoreTicks.GetDate());
            Assert.AreEqual(_tickNumber + ticksToAdvance, tenMoreTicks.GetTick());
        }
Ejemplo n.º 10
0
 public void Constructor()
 {
     Assert.AreEqual(_tickNumber, _tick.GetTick());
     Assert.AreEqual(_time, _tick.GetDate());
 }