コード例 #1
0
            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));
                });
            }
コード例 #2
0
 public static LicenseEntity ToEntity(this InsertLicenseCommand command)
 {
     return(new LicenseEntity
     {
         Id = command.Id,
         Key = command.Key,
         Created = command.Created,
         UserId = command.UserId
     });
 }
コード例 #3
0
            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));
                });
            }