Ejemplo n.º 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 = FakeTimeCalculatorFactory.GetTimeWarpStateCalculator();
            var account      = new Account(accountId, "ashley", "*****@*****.**", "beans");
            var timeWarpUser = new TimeWarpUser(account, calc);

            var usersCache = new UsersCache(new[] { timeWarpUser });

            var controller = new UserStateController(usersCache, 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);
        }
Ejemplo n.º 2
0
        public void CreateNewAccountTest()
        {
            var accountsCache  = new AccountsCache(Enumerable.Empty <Account>());
            var userStateCache = new UsersCache(Enumerable.Empty <TimeWarpUser>());
            var persistence    = new FakeEntityPersistence <Account>();
            var calc           = FakeTimeCalculatorFactory.GetTimeWarpStateCalculator();
            AccountController accountController = new AccountController(accountsCache, persistence, userStateCache, calc);

            var result = accountController.Post("new user", "eamil@sdaisd", "newPassword");

            var stored = persistence.SavedItems.Single();

            Assert.AreEqual(0, result);
            Assert.AreEqual("new user", stored.Name);
            Assert.AreEqual("eamil@sdaisd", stored.Email);
        }
Ejemplo n.º 3
0
        public void Post()
        {
            // Arrange
            long accountId = 1;

            var fakeNowProvider = new FakeNowProvider();

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

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

            var usersCache = new UsersCache(new[] { timeWarpUser });

            var persistence = new FakeTimeWarpStatePersistence();


            var controller = new UserStateController(usersCache, 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);
        }