Ejemplo n.º 1
0
        public async Task ShouldRevoke(
            TestableContext context,
            Handler handler
            )
        {
            context.UoW.Plan <Role>(context.Id())
            .HasEvent <Events.Defined>(x =>
            {
                x.RoleId = context.Id();
            });

            var command = new Commands.Revoke
            {
                RoleId = context.Id()
            };
            await handler.Handle(command, context).ConfigureAwait(false);

            context.UoW.Check <Role>(context.Id()).Raised <Events.Revoked>();
        }
Ejemplo n.º 2
0
        public async Task ShouldNotRevokeDestroyed(
            TestableContext context,
            Handler handler
            )
        {
            context.UoW.Plan <Role>(context.Id())
            .HasEvent <Events.Defined>(x =>
            {
                x.RoleId = context.Id();
            })
            .HasEvent <Events.Destroyed>(x =>
            {
                x.RoleId = context.Id();
            });

            var command = new Commands.Revoke
            {
                RoleId = context.Id()
            };

            await Assert.ThrowsAsync <BusinessException>(() => handler.Handle(command, context)).ConfigureAwait(false);
        }
Ejemplo n.º 3
0
        public async Task Handle(Commands.Revoke command, IMessageHandlerContext ctx)
        {
            var role = await ctx.For <Role>().Get(command.RoleId).ConfigureAwait(false);

            role.Revoke();
        }