Info
Version: | 4.1.3 |
Author(s): | Chris F Carroll |
Last Update: | Thursday, November 28, 2024 |
.NET Fiddle: | Create the first Fiddle |
Project Url: | https://github.com/chrisfcarroll/TestBase |
NuGet Url: | https://www.nuget.org/packages/Extensions.Logging.ListOfString |
Install
Install-Package Extensions.Logging.ListOfString
dotnet add package Extensions.Logging.ListOfString
paket add Extensions.Logging.ListOfString
Extensions.Logging.ListOfString Download (Unzip the "nupkg" after downloading)
Dependencies
Tags
```
ILoggerFactory factory=new LoggerFactory.AddProvider(new StringListLoggerProvider())
ILogger logger= factory.CreateLogger("Test1");
...tests..
;
StringListLogger.Instance
.LoggedLines
.ShouldContain(x=>x.Matches("kilroy was here"));
```
or
```
var loggedLines = new List<string>();
var logger= new LoggerFactory().AddStringListLogger(loggedLines).CreateLogger("Test2");
...tests..;
loggedLines .ShouldContain(x=>x.Matches("kilroy was here too."));
```
This is for Microsoft.Extensions.Logging.Abstractions.
For Serilog, see https://www.nuget.org/packages/Serilog.Sinks.ListOfString/
Part of https://www.nuget.org/packages/TestBase
*TestBase* gives you a flying start to unit testing with fluent assertions that are easy to extend, and
tools for testing with dependencies on AspNetMvc, HttpClient, Ado.Net, Streams and Loggers.