Example #1
0
        public void MoveByTimeIgnoreTest()
        {
            // NOTE : Arrange.
            var mock = new Mock<IWatch>();
            mock.Setup(w => w.Now()).Returns(new DateTime(2013, 01, 22, 10, 00, 00));
            const int INTERVAL = 5;
            var m = new SlothMoveByTimeEco<object>(() => null, new TimeSpan(0, INTERVAL, 0), default(int), mock.Object);
            m.Move(0);

            // NOTE : Act.
            mock.Setup(w => w.Now()).Returns(new DateTime(2013, 01, 22, 10, INTERVAL * 2, 00));
            var isneed = m.IsNeedMove;

            // NOTE : Assert.
            Assert.IsFalse(isneed, "Двигаться нет смысла.");
        }
Example #2
0
        public void MoveByTimeTest()
        {
            // NOTE : Arrange.
            var mock = new Mock<IWatch>();
            mock.Setup(w => w.Now()).Returns(new DateTime(2013, 01, 22, 10, 00, 00));
            var m = new SlothMoveByTimeEco<object>(() => null, new TimeSpan(0, 20, 0), default(int), mock.Object);
            m.Move(0);

            // NOTE : Act.
            mock.Setup(w => w.Now()).Returns(new DateTime(2013, 01, 22, 10, 10, 00));
            var r = m.Result;
            mock.Setup(w => w.Now()).Returns(new DateTime(2013, 01, 22, 10, 25, 00));
            var isneed = m.IsNeedMove;

            // NOTE : Assert.
            Assert.IsTrue(isneed, "Двигаться нужно, т.к. был хит.");
        }
Example #3
0
        public void NeedMoveFirstTimeTest()
        {
            // NOTE : Arrange.
            var mock = new Mock<IWatch>();
            mock.Setup(w => w.Now()).Returns(new DateTime(2013, 01, 22));
            var m = new SlothMoveByTimeEco<object>(() => null, new TimeSpan(100, 0, 0), default(int), mock.Object);

            // NOTE : Act.
            var isneed = m.IsNeedMove;

            // NOTE : Assert.
            Assert.IsTrue(isneed);
        }