-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #228 from agehrke/flushasync
Implement IAsyncDisposable and use FlushAsync on TelemetryClient
- Loading branch information
Showing
4 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
test/Serilog.Sinks.ApplicationInsights.Tests/DisposableTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace Serilog.Sinks.ApplicationInsights.Tests; | ||
|
||
public class DisposableTest : ApplicationInsightsTest | ||
{ | ||
[Fact] | ||
public void Flush_is_called_on_channel_when_logger_is_disposed() | ||
{ | ||
((IDisposable)Logger).Dispose(); | ||
Assert.True(Channel.FlushCalled, "Channel.Flush was not called"); | ||
} | ||
|
||
#if NET6_0_OR_GREATER | ||
[Fact] | ||
public async Task FlushAsync_is_called_on_channel_when_logger_is_disposed_asynchronously() | ||
{ | ||
await ((IAsyncDisposable)Logger).DisposeAsync(); | ||
Assert.True(Channel.FlushAsyncCalled, "Channel.FlushAsync was not called"); | ||
} | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters