Exemplo n.º 1
0
        public void Can_insert_a_user()
        {
            // setup
            _testUser = GetTestUser();

            // act
            UserRepositoy.Insert(_testUser);

            // assert
            (_testUser.Id > 0).ShouldBeTrue();
            var dbUser = UserService.GetUserById(_testUser.Id);

            GetUserComparer().Equals(_testUser, dbUser).ShouldBeTrue();
        }
Exemplo n.º 2
0
        public void Deleting_a_system_user_throws_an_error()
        {
            // setup
            Can_insert_a_user();
            _testUser.IsSystemAccount = true;
            UserRepositoy.Update(_testUser);

            // act/assert
            try
            {
                UserService.DeleteUser(_testUser.Id);
                Assert.Fail("UserRepositoy.Delete didn't throw an error when trying to delete a system account.");
            }catch (Exception ex)
            {
                ex.Message.ShouldEqual("You cannot delete a system account");
            }
        }
Exemplo n.º 3
0
        private void CreateSampleUsers()
        {
            var role1 = UserRoleRepository.Insert(GetTestUserRole(1));
            var role2 = UserRoleRepository.Insert(GetTestUserRole(2));

            for (var x = 0; x < 43; x++)
            {
                var user = UserRepositoy.Insert(GetTestUser(x));
                switch (x % 3)
                {
                case 0:
                    UserService.AddUserToRole(user.Id, role1.SystemName);
                    break;

                case 1:
                    UserService.AddUserToRole(user.Id, role2.SystemName);
                    break;

                case 2:
                    break;
                }
            }
        }