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); }
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; } }
private static void VerifyRoleCount(int expected) { UserDbContext.Borrow(context => Assert.AreEqual(expected, context.webpages_Roles.Count())); }