-
Notifications
You must be signed in to change notification settings - Fork 29
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 #78 from serilog/dev
4.1.0 Release
- Loading branch information
Showing
6 changed files
with
293 additions
and
18 deletions.
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
60 changes: 60 additions & 0 deletions
60
test/Serilog.Sinks.PeriodicBatching.Tests/BackwardsCompatibilityTests.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,60 @@ | ||
#if FEATURE_ASYNCDISPOSABLE | ||
|
||
using Serilog.Sinks.PeriodicBatching.Tests.Support; | ||
using Serilog.Tests.Support; | ||
using Xunit; | ||
|
||
namespace Serilog.Sinks.PeriodicBatching.Tests; | ||
|
||
public class BackwardsCompatibilityTests | ||
{ | ||
static readonly TimeSpan TinyWait = TimeSpan.FromMilliseconds(200); | ||
|
||
[Fact] | ||
public void LegacyWhenAnEventIsEnqueuedItIsWrittenToABatchOnDispose() | ||
{ | ||
var bs = new LegacyDisposeTrackingSink(); | ||
var evt = Some.InformationEvent(); | ||
bs.Emit(evt); | ||
bs.Dispose(); | ||
var batch = Assert.Single(bs.Batches); | ||
var batched = Assert.Single(batch); | ||
Assert.Same(evt, batched); | ||
Assert.True(bs.IsDisposed); | ||
Assert.False(bs.WasCalledAfterDisposal); | ||
} | ||
|
||
[Fact] | ||
public void LegacyWhenAnEventIsEnqueuedItIsWrittenToABatchOnTimer() | ||
{ | ||
var bs = new LegacyDisposeTrackingSink(); | ||
var evt = Some.InformationEvent(); | ||
bs.Emit(evt); | ||
Thread.Sleep(TinyWait + TinyWait); | ||
bs.Stop(); | ||
bs.Dispose(); | ||
Assert.Single(bs.Batches); | ||
Assert.True(bs.IsDisposed); | ||
Assert.False(bs.WasCalledAfterDisposal); | ||
} | ||
|
||
[Fact] | ||
public void LegacySinksAreDisposedWhenLoggerIsDisposed() | ||
{ | ||
var sink = new LegacyDisposeTrackingSink(); | ||
var logger = new LoggerConfiguration().WriteTo.Sink(sink).CreateLogger(); | ||
logger.Dispose(); | ||
Assert.True(sink.IsDisposed); | ||
} | ||
|
||
[Fact] | ||
public async Task LegacySinksAreDisposedWhenLoggerIsDisposedAsync() | ||
{ | ||
var sink = new LegacyDisposeTrackingSink(); | ||
var logger = new LoggerConfiguration().WriteTo.Sink(sink).CreateLogger(); | ||
await logger.DisposeAsync(); | ||
Assert.True(sink.IsDisposed); | ||
} | ||
} | ||
|
||
#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
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
Oops, something went wrong.