Пример #1
0
        public async Task ShouldGetModelForValidInformation()
        {
            var command = new CreateTenantCommand
            {
                Name        = "testtom",
                HostName    = "localhost1",
                Description = "test desc",
                CreatedBy   = 1,
                Logo        = new byte[] { 1 }
            };

            var tenantModel = await _commandHandler.Handle(command, CancellationToken.None);

            Assert.Null(tenantModel.Errors);

            Assert.Equal(command.Name, tenantModel.Items.Single().Name, ignoreCase: true);
        }
Пример #2
0
        public void Handle_GivenValidRequest_ShouldRaiseTenantCreatedNotification()
        {
            // Arrange
            var mediatorMock = new Mock <IMediator>();
            var sut          = new CreateTenantCommandHandler(_context, mediatorMock.Object);
            var newTenantId  = "100001";

            // Act
            var result = sut.Handle(new CreateTenantCommand {
                TenantId = newTenantId
            }, CancellationToken.None);

            // Assert
            mediatorMock.Verify(m => m.Publish(It.Is <TenantCreated>(cc => cc.TenantId == newTenantId), It.IsAny <CancellationToken>()), Times.Once);
        }