Beispiel #1
0
        public async Task LogMessageAsync_ShouldNotLog_WhenEmptyMessage()
        {
            //act
            await _logger.LogMessageAsync("", LogLevel.Error);

            //assert
            _console.DidNotReceiveWithAnyArgs().WriteLine(Arg.Any <string>());
        }
Beispiel #2
0
        public async Task LogMessageAsync_ShouldWriteIntoConsole_WhenProperMEssageAndLogLevel()
        {
            //arrange
            string   result;
            DateTime now;

            using (TextWriter writer = new StringWriter())
            {
                Console.SetOut(writer);
                Console.SetError(writer);
                now = DateTime.UtcNow;

                //act
                await _logger.LogMessageAsync("Test", LogLevel.Error);

                result = writer.ToString();
            }

            //assert
            Assert.Equal($"{LogLevel.Error}\t{now.ToString("yyyy-MM-dd_HH:mm:ss")}:\tTest\r\n", result);
        }