Пример #1
0
        public void CreateUserAndAccount_GivenExistingAdministrator_DoesNothing()
        {
            UserDbContext.Borrow(
                context =>
            {
                var user  = this.CreateUser(context);
                var admin = CreateAdminRole(context);
                AssociateUserWithAdminRole(user, admin);
                context.SaveChanges();
            });

            VerifyRoleCount(1);

            this.RegisterUser();

            VerifyRoleCount(1);
        }
Пример #2
0
        public void CreateUserAndAccount_GivenNoExistingRolesAndExistingUsers_ThrowsException()
        {
            UserDbContext.Borrow(
                context =>
            {
                this.CreateUser(context);
                this.CreateUser(context);
                context.SaveChanges();
            });


            try
            {
                this.RegisterUser();
            }
            catch (CanNotCreateAdministratorException e)
            {
                VerifyRoleCount(1);
                throw;
            }
        }
Пример #3
0
 private static void VerifyRoleCount(int expected)
 {
     UserDbContext.Borrow(context => Assert.AreEqual(expected, context.webpages_Roles.Count()));
 }