-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
107 additions
and
7 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
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
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
73 changes: 73 additions & 0 deletions
73
test/DotNetNew.SteeltoeWebApi.Test/DynamicLoggerOptionTest.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,73 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Xml.Linq; | ||
using FluentAssertions; | ||
using Steeltoe.DotNetNew.Test.Utilities.Assertions; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Steeltoe.DotNetNew.SteeltoeWebApi.Test | ||
{ | ||
public class DynamicLoggerOptionTest : Test | ||
{ | ||
public DynamicLoggerOptionTest(ITestOutputHelper logger) : base("dynamic-logger", logger) | ||
{ | ||
} | ||
|
||
[Fact] | ||
public override async void TestHelp() | ||
{ | ||
using var sandbox = await TemplateSandbox("--help"); | ||
sandbox.CommandOutput.Should().ContainSnippet(@" | ||
--dynamic-logger Use dynamic logger. | ||
bool - Optional | ||
Default: false | ||
"); | ||
} | ||
|
||
[Fact] | ||
public async void TestCsproj() | ||
{ | ||
using var sandbox = await TemplateSandbox(); | ||
var xDoc = await sandbox.GetXmlDocumentAsync($"{sandbox.Name}.csproj"); | ||
var expectedPackageRefs = new List<string> | ||
{ | ||
"Steeltoe.Extensions.Logging.DynamicLogger", | ||
}; | ||
var actualPackageRefs = | ||
( | ||
from e in xDoc.Elements().Elements("ItemGroup").Elements("PackageReference").Attributes("Include") | ||
select e.Value | ||
).ToList(); | ||
actualPackageRefs.Should().Contain(expectedPackageRefs); | ||
} | ||
|
||
[Fact] | ||
public async void TestProgramCs() | ||
{ | ||
using var sandbox = await TemplateSandbox(); | ||
var programSource = await sandbox.GetFileTextAsync("Program.cs"); | ||
programSource.Should().ContainSnippet("using Steeltoe.Extensions.Logging;"); | ||
programSource.Should() | ||
.ContainSnippet(".ConfigureLogging((context, builder) => builder.AddDynamicConsole())"); | ||
} | ||
|
||
[Fact] | ||
public async void TestProgramCsNetCoreApp21() | ||
{ | ||
using var sandbox = await TemplateSandbox("--framework netcoreapp2.1"); | ||
var programSource = await sandbox.GetFileTextAsync("Program.cs"); | ||
programSource.Should().ContainSnippet("using Steeltoe.Extensions.Logging;"); | ||
programSource.Should() | ||
.ContainSnippet( | ||
"loggingBuilder.AddConfiguration(hostingContext.Configuration.GetSection(\"Logging\"));"); | ||
programSource.Should().ContainSnippet(@" | ||
.ConfigureLogging((hostingContext, loggingBuilder) => | ||
{ | ||
loggingBuilder.AddConfiguration(hostingContext.Configuration.GetSection(""Logging"")); | ||
loggingBuilder.AddDynamicConsole(); | ||
}) | ||
"); | ||
} | ||
} | ||
} |