Ejemplo n.º 1
0
        public void Multiple_roles_with_the_same_key_cannot_be_created()
        {
            var service = new UserService();

            var u1 = User.Create(service, _cu, new UserKey("1"), "name");

            //simulate saving to the eventstore
            u1.GetUncommittedEvents().ForEach(service.Project);

            Should
                .Throw<DuplicateUserException>(() => User.Create(service, _cu, new UserKey("1"), "new"))
                .Message
                .ShouldBe("There is already a User with the key '1'");
        }
Ejemplo n.º 2
0
        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)
            });
        }
Ejemplo n.º 3
0
        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);
        }