public async Task GivenLicense_InsertsLicenseIntoDatabase() { // Arrange var cancellationToken = new CancellationToken(); var command = new InsertLicenseCommand { Id = Guid.NewGuid(), UserId = Guid.NewGuid() }; // Act var result = await _classUnderTest.Handle(command, cancellationToken); // Assert var entity = await _licenseCollection .Find(x => x.Id == command.Id) .FirstOrDefaultAsync(cancellationToken); Assert.Multiple(() => { Assert.That(result, Is.Not.Null); Assert.That(entity.UserId, Is.EqualTo(command.UserId)); }); }
public static LicenseEntity ToEntity(this InsertLicenseCommand command) { return(new LicenseEntity { Id = command.Id, Key = command.Key, Created = command.Created, UserId = command.UserId }); }
public void GivenInsertLicenseCommandWithProducts_ReturnsLicenseEntity() { // Arrange var command = new InsertLicenseCommand { Id = Guid.NewGuid(), UserId = Guid.NewGuid() }; // Act var result = command.ToEntity(); // Assert Assert.Multiple(() => { Assert.That(result.Id, Is.EqualTo(command.Id)); Assert.That(result.UserId, Is.EqualTo(command.UserId)); }); }