public RolesTests() { _roleService = new RoleService(); _permissionService = new PermissionService(); _currentUser = new Operator { Name = "Current User", Key = "cu", CanCreatePermissions = true, CanCreateRoles = true }; }
public void Adding_the_same_role_to_a_user_multiple_times_does_nothing() { var userService = new UserService(); var user = User.Create(userService, _cu, new UserKey("theuser"), "the user"); var roleService = new RoleService(); var role = Role.Create(roleService, _cu, new RoleKey("role"), "the-role", ""); user.AddRole(_cu, role.ID); user.AddRole(_cu, role.ID); user.GetUncommittedEvents().Select(e => e.GetType()).ShouldBe(new[] { typeof(UserCreatedEvent), typeof(RoleAddedToUserEvent) }); }
public Boot( Projectionist projectionist, AggregateStore<Guid> store, UserService users, RoleService roles, PermissionService permissions, CollectionsReadModel collectionsReadModel, HistoryReadModel history, AuthorizationReadModel authorizationRead) { _projectionist = projectionist; _store = store; projectionist .Add(users) .Add(roles) .Add(permissions) .Add(collectionsReadModel.Project) .Add(history.Project) .Add(authorizationRead.Project); }
public void Multiple_roles_with_the_same_key_cannot_be_created() { var service = new RoleService(); var r1 = Role.Create(service, _currentUser, new RoleKey("1"), "name", "desc"); //simulate saving to the eventstore r1.GetUncommittedEvents().ForEach(service.Project); Should .Throw<DuplicateRoleException>(() => Role.Create(service, _currentUser, new RoleKey("1"), "new", "newer")) .Message .ShouldBe("There is already a Role with the key '1'"); }