From 5b45b9bf5d3fbf796cd4382405e59e9e0e53dc1b Mon Sep 17 00:00:00 2001 From: martincostello Date: Mon, 20 Aug 2018 18:38:24 +0100 Subject: [PATCH] Update examples in README Update the examples in the README to reference the changes from #7. --- README.md | 4 ++- .../{Example.cs => Examples.cs} | 32 +++++++++---------- 2 files changed, 19 insertions(+), 17 deletions(-) rename tests/Logging.XUnit.Tests/{Example.cs => Examples.cs} (90%) diff --git a/README.md b/README.md index b893bd7..edf376b 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,9 @@ namespace MyApp.Calculator } ``` -See [here](https://github.com/martincostello/xunit-logging/blob/master/tests/Logging.XUnit.Tests/Example.cs "Example test") for more examples. +See below for links to more examples: + 1. [Unit tests](https://github.com/martincostello/xunit-logging/blob/master/tests/Logging.XUnit.Tests/Examples.cs "Unit test examples") + 1. [Integration tests for an ASP.NET Core HTTP application](https://github.com/martincostello/xunit-logging/blob/master/tests/Logging.XUnit.Tests/Integration/HttpApplicationTests.cs "Integration test examples") ## Feedback diff --git a/tests/Logging.XUnit.Tests/Example.cs b/tests/Logging.XUnit.Tests/Examples.cs similarity index 90% rename from tests/Logging.XUnit.Tests/Example.cs rename to tests/Logging.XUnit.Tests/Examples.cs index 9744904..873aa6c 100644 --- a/tests/Logging.XUnit.Tests/Example.cs +++ b/tests/Logging.XUnit.Tests/Examples.cs @@ -10,19 +10,32 @@ namespace MartinCostello.Logging.XUnit { - public class Example + public class Examples { - public Example(ITestOutputHelper outputHelper) + public Examples(ITestOutputHelper outputHelper) { OutputHelper = outputHelper; } private ITestOutputHelper OutputHelper { get; } + [Fact] + public void Calculator_Sums_Two_Equal_Integers() + { + // Arrange using conversion to a logger + var calculator = new Calculator(OutputHelper.ToLogger()); + + // Act + int actual = calculator.Sum(2, 2); + + // Assert + actual.ShouldBe(4); + } + [Fact] public void Calculator_Sums_Two_Different_Integers() { - // Arrange + // Arrange using the logging provider var services = new ServiceCollection() .AddLogging((builder) => builder.AddXUnit(OutputHelper)) .AddSingleton(); @@ -38,19 +51,6 @@ public void Calculator_Sums_Two_Different_Integers() actual.ShouldBe(3); } - [Fact] - public void Calculator_Sums_Two_Equal_Integers() - { - // Arrange - var calculator = new Calculator(OutputHelper.ToLogger()); - - // Act - int actual = calculator.Sum(2, 2); - - // Assert - actual.ShouldBe(4); - } - private sealed class Calculator { private readonly ILogger _logger;