コード例 #1
0
        public void Get()
        {
            // Arrange
            long accountId = 1;

            var fakeNowProvider = new FakeNowProvider();

            fakeNowProvider.Now = new DateTime(2000, 12, 12, 12, 12, 0);

            ITimeWarpStateCalculator calc = GetTimeWarpStateCalculator();
            var account      = new TimeWarpAccount(accountId, "ashley", "*****@*****.**", "beans");
            var timeWarpUser = new TimeWarpUser(account, calc);

            IUsers users = new Users(new[] { timeWarpUser });

            var controller = new TimeWarpUserController(users, fakeNowProvider, new FakeTimeWarpStatePersistence());

            //act
            fakeNowProvider.Now = new DateTime(2000, 12, 12, 12, 12, 0, 5);
            var result = controller.Get(accountId);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(accountId, result.AccountId);
            Assert.AreEqual(Public.Models.v001.TimeWarpState.None, result.State);
        }
コード例 #2
0
        public void Post()
        {
            // Arrange
            long accountId = 1;

            var fakeNowProvider = new FakeNowProvider();

            fakeNowProvider.Now = new DateTime(2000, 12, 12, 12, 12, 0);

            ITimeWarpStateCalculator calc = GetTimeWarpStateCalculator();
            var account      = new TimeWarpAccount(accountId, "ashley", "*****@*****.**", "beans");
            var timeWarpUser = new TimeWarpUser(account, calc);

            IUsers users = new Users(new[] { timeWarpUser });

            var persistence = new FakeTimeWarpStatePersistence();


            var controller = new TimeWarpUserController(users, fakeNowProvider, persistence);

            //act

            controller.Post(accountId, TimeWarpCommand.Rest);

            fakeNowProvider.Now = new DateTime(2000, 12, 12, 12, 12, 0, 5);
            var result = controller.Get(accountId);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(accountId, result.AccountId);
            Assert.AreEqual(Public.Models.v001.TimeWarpState.Resting, result.State);
            Assert.AreEqual(TimeSpan.FromMilliseconds(095), result.TimeLeft);

            Assert.AreEqual(0.050000000000000044d, result.Progress);
            Assert.AreEqual(new DateTime(2000, 12, 12, 12, 12, 0, 0), result.PeriodStartTime);
        }