예제 #1
0
        public void CanAddUserToRoom()
        {
            var room              = new Room(0, TestHelper.RoomName, new DateTime(2000, 12, 12));
            var account1          = TestHelper.AccountMock();
            var account2          = TestHelper.AccountMock();
            var accountRepository = new AccountRepository();
            var roomRepository    = new RoomRepository();

            roomRepository.Add(room);

            accountRepository.Add(account1);
            accountRepository.Add(account2);

            room.Add(account1);
            room.Add(account2);

            roomRepository.Add(room);

            var  roomRepository2 = new RoomRepository();
            Room result          = roomRepository2.GetRoom(room.Id);

            Assert.AreEqual(2, result.Users.Count());


            var rooms = roomRepository2.GetRooms(account1.Id);

            Assert.AreEqual(1, rooms.Count());
        }
예제 #2
0
        private static AuthenticationSession GetAuthenticationSession(AuthenticationSessionRepository authenticationSessionRepository, DateTime now)
        {
            DateTime dateTime = new DateTime(2012, 12, 12);
            var      account1 = TestHelper.AccountMock();

            var accountRepository = new AccountRepository();

            accountRepository.Add(account1);

            var authenticationSession = new AuthenticationSession(account1, "testToken" + now.Ticks, dateTime);

            authenticationSessionRepository.Add(authenticationSession);

            Assert.That(authenticationSession.Id != 0);
            return(authenticationSession);
        }
예제 #3
0
        public void CanUpdateState()
        {
            var account = TestHelper.AccountMock();
            var state1  = new TimeWarpUserState(account, TimeWarpState.Working, new DateTime(2000, 12, 12, 12, 12, 12),
                                                new TimeSpan(1, 30, 2), 3.0, 4);
            var state2 = new TimeWarpUserState(account, TimeWarpState.Resting, new DateTime(2001, 12, 12, 12, 12, 12),
                                               new TimeSpan(1, 30, 2), 3.0, 3);

            CreateInitialValuesInDatabase(account, state1, state2);

            var timeWarpUserState = UpdateValuesInDatabase(account);

            Assert.IsNotNull(timeWarpUserState);
            Assert.AreEqual(account.Id, timeWarpUserState.Account.Id);
            Assert.AreEqual(account.Name, timeWarpUserState.Account.Name);
            Assert.AreEqual(TimeWarpState.Resting, timeWarpUserState.State);
            Assert.AreEqual(3, timeWarpUserState.AgentType);
        }
예제 #4
0
        public void CanAddNewAccounts()
        {
            var account1         = TestHelper.AccountMock();
            var account2         = TestHelper.AccountMock();
            var accountPassword1 = new AccountPassword(account1, "hello1");
            var accountPassword2 = new AccountPassword(account2, "hello2");

            var accountRepository         = new AccountRepository();
            var accountPasswordRepository = new AccountPasswordRepository();

            accountRepository.Add(account1);
            accountRepository.Add(account2);

            accountPasswordRepository.Add(accountPassword1);
            accountPasswordRepository.Add(accountPassword2);

            accountRepository.GetAll();
            var accountPasswords = accountPasswordRepository.GetAll();

            Assert.That(account1.Id != 0);
            Assert.That(account2.Id != 0);

            Assert.That(accountPasswords.Count != 0);
        }