Added all files and readme
92454e61
Ryan Andersen
committed
4 changed files
FakeItEasy.DotnetCore.LoggerExtensions.csproj
/FakeItEasy.DotnetCore.LoggerExtensions/FakeItEasy.DotnetCore.LoggerExtensions.csproj+20
/FakeItEasy.DotnetCore.LoggerExtensions/FakeItEasy.DotnetCore.LoggerExtensions.csproj
Add comment 1 Plus  <Project Sdk="Microsoft.NET.Sdk">
Add comment 2 Plus  
Add comment 3 Plus   <PropertyGroup>
Add comment 4 Plus   <TargetFramework>netstandard2.0</TargetFramework>
Add comment 5 Plus   <Authors>Ryan Andersen</Authors>
Add comment 6 Plus   <Company>Bride Butler</Company>
Add comment 7 Plus   <Description>FakeIteasy.DotnetCore.LoggerExtensions provides a simple way to assert calls to a logger happened using two simple to use extension methods.</Description>
Add comment 8 Plus   <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Add comment 9 Plus   <PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
Add comment 10 Plus   <PackageLicenseUrl>http://opensource.org/licenses/MIT</PackageLicenseUrl>
Add comment 11 Plus   <RepositoryUrl>https://BrideButler@dev.azure.com/BrideButler/Bride%20Butler%20Open%20Source/_git/FakeItEasy.DotnetCore.LoggerExtensions</RepositoryUrl>
Add comment 12 Plus   </PropertyGroup>
Add comment 13 Plus  
Add comment 14 Plus   <ItemGroup>
Add comment 15 Plus   <PackageReference Include="FakeItEasy" Version="5.0.1" />
Add comment 16 Plus   <PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" />
Add comment 17 Plus   </ItemGroup>
Add comment 18 Plus  
Add comment 19 Plus  </Project>
Add comment 20 Plus  
LoggerExtensions.cs
/FakeItEasy.DotnetCore.LoggerExtensions/LoggerExtensions.cs+45
/FakeItEasy.DotnetCore.LoggerExtensions/LoggerExtensions.cs
Add comment 1 Plus  using System;
Add comment 2 Plus  using FakeItEasy.Configuration;
Add comment 3 Plus  using Microsoft.Extensions.Logging;
Add comment 4 Plus  using Microsoft.Extensions.Logging.Internal;
Add comment 5 Plus  
Add comment 6 Plus  namespace FakeItEasy.DotnetCore.LoggerExtensions
Add comment 7 Plus  {
Add comment 8 Plus   public static class LoggerExtensions
Add comment 9 Plus   {
Add comment 10 Plus   public static void VerifyLogMustHaveHappened<T>(this ILogger<T> logger, LogLevel level, string message)
Add comment 11 Plus   {
Add comment 12 Plus   try
Add comment 13 Plus   {
Add comment 14 Plus   logger.VerifyLog(level, message)
Add comment 15 Plus   .MustHaveHappened();
Add comment 16 Plus   }
Add comment 17 Plus   catch (Exception e)
Add comment 18 Plus   {
Add comment 19 Plus   throw new ExpectationException($"while verifying a call to log with message: \"{message}\"", e);
Add comment 20 Plus   }
Add comment 21 Plus   }
Add comment 22 Plus  
Add comment 23 Plus   public static void VerifyLogMustNotHaveHappened<T>(this ILogger<T> logger, LogLevel level, string message)
Add comment 24 Plus   {
Add comment 25 Plus   try
Add comment 26 Plus   {
Add comment 27 Plus   logger.VerifyLog(level, message)
Add comment 28 Plus   .MustNotHaveHappened();
Add comment 29 Plus   }
Add comment 30 Plus   catch (Exception e)
Add comment 31 Plus   {
Add comment 32 Plus   throw new ExpectationException($"while verifying a call to log with message: \"{message}\"", e);
Add comment 33 Plus   }
Add comment 34 Plus   }
Add comment 35 Plus  
Add comment 36 Plus   public static IVoidArgumentValidationConfiguration VerifyLog<T>(this ILogger<T> logger, LogLevel level,
Add comment 37 Plus   string message)
Add comment 38 Plus   {
Add comment 39 Plus   return A.CallTo(() => logger.Log(level, A<EventId>._,
Add comment 40 Plus   A<FormattedLogValues>.That.Matches(e => e.ToString().Contains(message)), A<Exception>._,
Add comment 41 Plus   A<Func<object, Exception, string>>._));
Add comment 42 Plus   }
Add comment 43 Plus   }
Add comment 44 Plus  }
Add comment 45 Plus  
FakeItEasy.DotnetCore.sln
/FakeItEasy.DotnetCore.sln+26
/FakeItEasy.DotnetCore.sln
Add comment 1 Plus  
Add comment 2 Plus  Microsoft Visual Studio Solution File, Format Version 12.00
Add comment 3 Plus  # Visual Studio 15
Add comment 4 Plus  VisualStudioVersion = 15.0.28307.271
Add comment 5 Plus  MinimumVisualStudioVersion = 10.0.40219.1
Add comment 6 Plus  Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FakeItEasy.DotnetCore.LoggerExtensions", "FakeItEasy.DotnetCore.LoggerExtensions\FakeItEasy.DotnetCore.LoggerExtensions.csproj", "{DC440486-3215-4D27-84EA-29B3CABDD1B4}"
Add comment 7 Plus  EndProject
Add comment 8 Plus  Global
Add comment 9 Plus   GlobalSection(SolutionConfigurationPlatforms) = preSolution
Add comment 10 Plus   Debug|Any CPU = Debug|Any CPU
Add comment 11 Plus   Release|Any CPU = Release|Any CPU
Add comment 12 Plus   EndGlobalSection
Add comment 13 Plus   GlobalSection(ProjectConfigurationPlatforms) = postSolution
Add comment 14 Plus   {DC440486-3215-4D27-84EA-29B3CABDD1B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
Add comment 15 Plus   {DC440486-3215-4D27-84EA-29B3CABDD1B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
Add comment 16 Plus   {DC440486-3215-4D27-84EA-29B3CABDD1B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
Add comment 17 Plus   {DC440486-3215-4D27-84EA-29B3CABDD1B4}.Release|Any CPU.Build.0 = Release|Any CPU
Add comment 18 Plus   EndGlobalSection
Add comment 19 Plus   GlobalSection(SolutionProperties) = preSolution
Add comment 20 Plus   HideSolutionNode = FALSE
Add comment 21 Plus   EndGlobalSection
Add comment 22 Plus   GlobalSection(ExtensibilityGlobals) = postSolution
Add comment 23 Plus   SolutionGuid = {1CD51923-B88F-4B2E-BD0D-2AB15FEDDD61}
Add comment 24 Plus   EndGlobalSection
Add comment 25 Plus  EndGlobal
Add comment 26 Plus  
README.md
/README.md-16+21
Windows-1252 -> utf-8
/README.md
Add comment 1 Minus  # Introduction
Add comment 2 Minus  TODO: Give a short introduction of your project. Let this section explain the objectives or the motivation behind this project.
Add comment 1 Plus  # FakeItEasy.DotnetCore.LoggerExtensions
Add comment 2 Plus  
Add comment 3 Plus  FakeIteasy.DotnetCore.LoggerExtensions provides a simple way to assert calls to a logger happened using simple to use extension methods.
Add comment 4 Plus  
Add comment 5 Plus  
Add comment 6 Plus  # Use
Add comment 7 Plus  
Add comment 8 Plus  In your Test Create a fake ILogger<T>
Add comment 9 Plus  
Add comment 10 Plus   var fakeLogger = A.Fake<ILogger<T>>();
Add comment 11 Plus  
Add comment 12 Plus  Pass your fake logger into the class that uses the logger
Add comment 13 Plus  
Add comment 14 Plus   var sut = new SystemUnderTest(fakeLogger);
Add comment 15 Plus  
Add comment 16 Plus  After performing the actions of your tests simply call the appropriate methods on the fake logger to assert logs happened, or didn't happen based on a few criteria
Add comment 17 Plus  
Add comment 18 Plus   _fakeLogger.VerifyLogMustHaveHappened(LogLevel.Error, "Failed");
Add comment 19 Plus   _fakeLogger.VerifyLogMustNotHaveHappened(LogLevel.Error, "Failed");
Add comment 3 20
Add comment 4 Minus  # Getting Started
Add comment 5 Minus  TODO: Guide users through getting your code up and running on their own system. In this section you can talk about:
Add comment 6 Minus  1. Installation process
Add comment 7 Minus  2. Software dependencies
Add comment 8 Minus  3. Latest releases
Add comment 9 Minus  4. API references
Add comment 21 Plus  If you want to use more of the built in FakeItEasy argument validations call the VerifyLog method
Add comment 10 22
Add comment 11 Minus  # Build and Test
Add comment 12 Minus  TODO: Describe and show how to build your code and run the tests.
Add comment 23 Plus   _fakeLogger.VerifyLog(LogLevel.Error, "Failed").MustHaveHappenedTwiceOrMore();
Add comment 13 24
Add comment 14 Minus  # Contribute
Add comment 15 Minus  TODO: Explain how other users and developers can contribute to make your code better.
Add comment 16 25
Add comment 17 26
Add comment 17 Minus  If you want to learn more about creating good readme files then refer the following [guidelines](https://www.visualstudio.com/en-us/docs/git/create-a-readme). You can also seek inspiration from the below readme files:
Add comment 18 Minus  - [ASP.NET Core](https://github.com/aspnet/Home)
Add comment 19 Minus  - [Visual Studio Code](https://github.com/Microsoft/vscode)
Add comment 20 Minus  - [Chakra Core](https://github.com/Microsoft/ChakraCore)