示例#1
0
        public async Task ShouldDeactivate(
            TestableContext context,
            Handler handler
            )
        {
            context.UoW.Plan <Role>(context.Id())
            .HasEvent <Events.Defined>(x =>
            {
                x.RoleId = context.Id();
            });

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

            context.UoW.Check <Role>(context.Id()).Raised <Events.Deactivated>();
        }
示例#2
0
        public async Task ShouldNotDeactivateDestroyed(
            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.Deactivate
            {
                RoleId = context.Id()
            };
            await Assert.ThrowsAsync <BusinessException>(() => handler.Handle(command, context)).ConfigureAwait(false);
        }
示例#3
0
        public async Task Handle(Commands.Deactivate command, IMessageHandlerContext ctx)
        {
            var role = await ctx.For <Role>().Get(command.RoleId).ConfigureAwait(false);

            role.Deactivate();
        }