示例#1
0
        public async Task Should_unallocate_by_user_id()
        {
            var user = await Context.Data.SeedUser();

            await Context.Data.SeedAllocation(user.Id);

            const int MINUTES = 1;
            await Context.Data.AllocateUser(user.Id, MINUTES);

            var allocationDetails = await _query.Handle(new GetAllocationByUserIdQuery(user.Id));

            allocationDetails.Allocated.Should().BeTrue();
            allocationDetails.ExpiresAt.Should()
            .BeCloseTo(DateTime.UtcNow.AddMinutes(MINUTES), TimeSpan.FromSeconds(5));

            var command = new UnallocateByUsernameCommand(user.Username);
            await _commandHandler.Handle(command);

            allocationDetails = await _query.Handle(new GetAllocationByUserIdQuery(user.Id));

            allocationDetails.Allocated.Should().BeFalse();
            allocationDetails.ExpiresAt.Should().BeNull();
        }
 private async Task Unallocate(string username)
 {
     var unallocateCommand = new UnallocateByUsernameCommand(username);
     await _commandHandler.Handle(unallocateCommand);
 }