-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce InMemorySinkSnapshot to reduce the chance of assertions blo…
…wing up.
- Loading branch information
1 parent
da82aae
commit 5108686
Showing
6 changed files
with
97 additions
and
64 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
62 changes: 33 additions & 29 deletions
62
src/Serilog.Sinks.InMemory.Assertions/Serilog.Sinks.InMemory.Assertions.csproj
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 |
---|---|---|
@@ -1,36 +1,40 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<IsPackable>true</IsPackable> | ||
<Version>0.9.0</Version> | ||
<Title>Serilog in-memory sink assertion extensions</Title> | ||
<Description>FluentAssertions extensions to use with the Serilog.Sinks.InMemory package</Description> | ||
<Copyright>2021 Sander van Vliet</Copyright> | ||
<Authors>Sander van Vliet</Authors> | ||
<PackageProjectUrl>https://github.com/sandermvanvliet/SerilogSinksInMemory/</PackageProjectUrl> | ||
<PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
<RepositoryUrl>https://github.com/sandermvanvliet/SerilogSinksInMemory/</RepositoryUrl> | ||
<RepositoryType>git</RepositoryType> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<IsPackable>true</IsPackable> | ||
<Version>0.9.1</Version> | ||
<Title>Serilog in-memory sink assertion extensions</Title> | ||
<Description>FluentAssertions extensions to use with the Serilog.Sinks.InMemory package</Description> | ||
<Copyright>2021 Sander van Vliet</Copyright> | ||
<Authors>Sander van Vliet</Authors> | ||
<PackageProjectUrl>https://github.com/sandermvanvliet/SerilogSinksInMemory/</PackageProjectUrl> | ||
<PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
<RepositoryUrl>https://github.com/sandermvanvliet/SerilogSinksInMemory/</RepositoryUrl> | ||
<RepositoryType>git</RepositoryType> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<PackageVersion>$(Version)$(VersionSuffix)</PackageVersion> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<PackageVersion>$(Version)$(VersionSuffix)</PackageVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="FluentAssertions" Version="5.*"> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="Serilog.Sinks.InMemory" Version="0.*"> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="Serilog" Version="2.*"> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="FluentAssertions" Version="5.*"> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="Serilog.Sinks.InMemory" Version="0.*"> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="Serilog" Version="2.*"> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Serilog.Sinks.InMemory\Serilog.Sinks.InMemory.csproj" Condition="'$(Configuration)'=='Debug'" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Serilog.Events; | ||
|
||
namespace Serilog.Sinks.InMemory | ||
{ | ||
/// <summary> | ||
/// A snapshot of an InMemorySink instance that is used for assertions | ||
/// </summary> | ||
internal class InMemorySinkSnapshot : InMemorySink | ||
{ | ||
public InMemorySinkSnapshot(List<LogEvent> logEvents) : base(logEvents) | ||
{ | ||
} | ||
|
||
public override void Emit(LogEvent logEvent) | ||
{ | ||
throw new InvalidOperationException("Can't write log events to a in-memory sink snapshot because it is a read-only representation"); | ||
} | ||
} | ||
} |
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