public void GivenUserId_BuildsWithUserId() { // Arrange var builder = new GetLicenseByUserIdQueryBuilder(); var userId = Guid.NewGuid(); // Act var result = builder.WithUserId(userId); var build = builder.Build(); // Assert Assert.Multiple(() => { Assert.That(result, Is.EqualTo(builder)); Assert.That(build.UserId, Is.EqualTo(build.UserId)); }); }
public async Task <LicenseDto> GetByUserIdAsync(Guid userId, CancellationToken token) { await ValidateUserExistsAsync(userId, token); var getLicenseByUserId = new GetLicenseByUserIdQueryBuilder() .WithUserId(userId) .Build(); var license = await _mediator.Send(getLicenseByUserId, token); if (license == null) { throw new EntityNotFoundException( $"No License With UserId: '{userId}' Found", ExceptionMessages.License.NoLicenseWithUserId); } return(license.ToDto()); }