public Task LogAsync(LogLevel level, string logMessage) { var logInfo = GetLogInfo(level); string message = GetMessage(logInfo.Item1, logMessage, _dateTimeProvider.UtcNow); return(_streamWriter.WriteLineAsync(_stream, message)); }
public async Task WriteFile_WhenStreamWriterThrows_ShouldReturnFalse() { var path = "path"; var list = new List <string> { "I", "am", "an", "item" }; _mockWriter.WriteLineAsync(Arg.Is(path), Arg.Is(list)) .Throws <Exception>(); var result = await _sut.WriteFile(path, list); result.Should().BeFalse(); }
public async Task Async_WriteLine_Shoud_Log_To_Stream_The_Expected_Message() { string message = LoggerProvider.CreateLogMessage(MessageLength.Small); using (var stream = new MemoryStream()) { await _streamWriter.WriteLineAsync(stream, message).ConfigureAwait(false); Assert.AreEqual(message, LoggerProvider.GetStreamContent(stream)); } }
public async Task <bool> WriteFile(string filePath, List <string> matches) { bool completed = true; try { await _streamWriter.WriteLineAsync(filePath, matches); } catch (Exception) { completed = false; } return(completed); }
public Task Serialize(Command command, IStreamWriter streamWriter) { return(streamWriter.WriteLineAsync(command.CommandString)); }