示例#1
0
        public async Task Deve_Incluir_Log_Valido()
        {
            var logCommand = CreateLogCommandTest.CommandValido();

            _projectRepository.GetByApiKey(Arg.Any <Guid>()).Returns(ProjectTest.GetProject());

            var result = await _handler.Handle(logCommand, CancellationToken.None);

            Assert.True(result == Guid.Empty);
            await _logRepository.Received().CreateAsync(Arg.Any <Log>());

            await _uow.Received().CommitAsync();
        }
示例#2
0
        public async Task CreateLogCommand_LogDataCreatedOnDatabase()
        {
            // Setup Test Request Parameters
            var createLogDto = new CreateLogDto
            {
                HostName = "TestHostName",
                Message  = "TestMessage",
                Severity = "Error"
            };
            var createLogCommand = new CreateLogCommand(createLogDto);
            // Expected Result
            var expectedResult = new CreatedLogDto()
            {
                Id          = 1,
                CreatedDate = new DateTime(20, 01, 01).Date,
                HostName    = "TestHostName",
                Message     = "TestMessage",
                Severity    = "Error"
            };

            var handler = new CreateLogCommandHandler(wrapperMock.Object);
            var result  = await handler.Handle(createLogCommand, new System.Threading.CancellationToken());

            Assert.AreEqual(expectedResult.ToString(), result.ToString());
        }