コード例 #1
0
        public Task LogAsync(LogLevel level, string logMessage)
        {
            var    logInfo = GetLogInfo(level);
            string message = GetMessage(logInfo.Item1, logMessage, _dateTimeProvider.UtcNow);

            return(_streamWriter.WriteLineAsync(_stream, message));
        }
コード例 #2
0
        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();
        }
コード例 #3
0
ファイル: StreamWriterTests.cs プロジェクト: BenGab/NXLogger
        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));
            }
        }
コード例 #4
0
        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);
        }
コード例 #5
0
 public Task Serialize(Command command, IStreamWriter streamWriter)
 {
     return(streamWriter.WriteLineAsync(command.CommandString));
 }