public async Task Should_get_allocation_details_by_user_id() { var user = await Context.Data.SeedUser(); var allocation = await Context.Data.SeedAllocation(user.Id); var allocationDetails = await _query.Handle(new GetAllocationByUserIdQuery(user.Id)); allocationDetails.UserId.Should().Be(user.Id); allocationDetails.Username.Should().Be(user.Username); allocationDetails.Allocated.Should().Be(allocation.Allocated); allocationDetails.ExpiresAt.Should().Be(allocation.ExpiresAt); }
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(); }