src/Serilog.Sinks.MicrosoftTeams.Tests/MicrosoftTeamsSinkTest.cs
/// <summary>
/// Tests the emitting of events.
/// </summary>
/// <param name="logEventLevel">The log event level.</param>
/// <param name="color">The color.</param>
/// <returns>A <see cref="Task"/> representing any asynchronous operation.</returns>
Tests the emitting of events.
Tests the emitting of events .
[Theory]
        [InlineData(LogEventLevel.Debug, "777777")]
        [InlineData(LogEventLevel.Error, "d9534f")]
        [InlineData(LogEventLevel.Fatal, "d9534f")]
        [InlineData(LogEventLevel.Information, "5bc0de")]
        [InlineData(LogEventLevel.Verbose, "777777")]
        [InlineData(LogEventLevel.Warning, "f0ad4e")]
        public async Task SinkEmitsEvents(LogEventLevel logEventLevel, string color)
        {
            const int MessageCount = 100;
            var sentMessagesTask = TestHelper.CaptureRequestsAsync(MessageCount);
            var renderedMessages = new List<string>();
            var templates = new List<string>();
            for (var i = 0; i < MessageCount; i++)
            {
                var templatePrefix = $"{Guid.NewGuid()} #";
                var template = templatePrefix + "{counter}";
                var renderedMessage = templatePrefix + i;
                renderedMessages.Add(renderedMessage);
                templates.Add(template);
                this.logger.Write(logEventLevel, template, i);
            }
            var actualMessages = await sentMessagesTask.ConfigureAwait(false);
            for (var i = 0; i < MessageCount; i++)
            {
                var occuredOn = actualMessages[i]["sections"][0]["facts"].Last.Last.Last.ToString();
                var expectedMessage = TestHelper.CreateMessage(templates[i], renderedMessages[i], logEventLevel, color, i, occuredOn);
                actualMessages[i].ShouldBe(expectedMessage);
            }
        }
[ Theory ] [ InlineData ( LogEventLevel . Debug , " " ) ] [ InlineData ( LogEventLevel . Error , " " ) ] [ InlineData ( LogEventLevel . Fatal , " " ) ] [ InlineData ( LogEventLevel . Information , " " ) ] [ InlineData ( LogEventLevel . Verbose , " " ) ] [ InlineData ( LogEventLevel . Warning , " " ) ] public async Task SinkEmitsEvents ( LogEventLevel logEventLevel , string color ) { const int MessageCount = 100 ; var sentMessagesTask = TestHelper . CaptureRequestsAsync ( MessageCount ) ; var renderedMessages = new List < string > ( ) ; var templates = new List < string > ( ) ; for ( var i = 0 ; i < MessageCount ; i ++ ) { var templatePrefix = $" { Guid . NewGuid ( ) }  # " ; var template = templatePrefix + " " ; var renderedMessage = templatePrefix + i ; renderedMessages . Add ( renderedMessage ) ; templates . Add ( template ) ; this . logger . Write ( logEventLevel , template , i ) ; } var actualMessages = await sentMessagesTask . ConfigureAwait ( false ) ; for ( var i = 0 ; i < MessageCount ; i ++ ) { var occuredOn = actualMessages [ i ] [ " " ] [ 0 ] [ " " ] . Last . Last . Last . ToString ( ) ; var expectedMessage = TestHelper . CreateMessage ( templates [ i ] , renderedMessages [ i ] , logEventLevel , color , i , occuredOn ) ; actualMessages [ i ] . ShouldBe ( expectedMessage ) ; } }
Tests the emitting of events.
Tests the emitting of events .
// ReSharper disable PossibleNullReferenceException
A  representing any asynchronous operation.
A representing any asynchronous operation .
logEventLevel
LogEventLevel
The log event level.
The log event level .
color
string
None