Skip to content

Commit

Permalink
AspNetWebRootPathLayoutRenderer - Added unit-test with parse and close (
Browse files Browse the repository at this point in the history
  • Loading branch information
snakefoot authored Aug 4, 2022
1 parent f3b247f commit 9b5b7db
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace NLog.Web.Tests.LayoutRenderers
{
public class AspNetEnvironmentLayoutRendererTests
public class AspNetEnvironmentLayoutRendererTests : TestBase
{
[Fact]
public void SuccessTest()
Expand All @@ -38,5 +38,16 @@ public void NullTest()
string actual = renderer.Render(new LogEventInfo());
Assert.Equal(string.Empty, actual);
}

[Fact]
public void InitCloseTest()
{
var logFactory = new LogFactory().Setup().RegisterNLogWeb().LoadConfiguration(builder =>
{
builder.ForTarget().WriteTo(new NLog.Targets.MemoryTarget() { Layout = "${aspnet-environment}" });
}).LogFactory;
Assert.NotNull(logFactory);
logFactory.Shutdown();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

namespace NLog.Web.Tests.LayoutRenderers
{
public class AspNetAppBasePathLayoutRendererTests
public class AspNetAppBasePathLayoutRendererTests : TestBase
{
[Fact]
public void SuccessTest()
Expand Down Expand Up @@ -61,5 +61,16 @@ public void NullTest()
Assert.Equal(AppContext.BaseDirectory, actual);
#endif
}

[Fact]
public void InitCloseTest()
{
var logFactory = new LogFactory().Setup().RegisterNLogWeb().LoadConfiguration(builder =>
{
builder.ForTarget().WriteTo(new NLog.Targets.MemoryTarget() { Layout = "${aspnet-appbasepath}" });
}).LogFactory;
Assert.NotNull(logFactory);
logFactory.Shutdown();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

namespace NLog.Web.Tests.LayoutRenderers
{
public class AspNetWebRootPathLayoutRendererTests
public class AspNetWebRootPathLayoutRendererTests : TestBase
{
[Fact]
public void SuccessTest()
Expand Down Expand Up @@ -57,5 +57,16 @@ public void NullTest()

Assert.Equal(string.Empty, actual);
}

[Fact]
public void InitCloseTest()
{
var logFactory = new LogFactory().Setup().RegisterNLogWeb().LoadConfiguration(builder =>
{
builder.ForTarget().WriteTo(new NLog.Targets.MemoryTarget() { Layout = "${aspnet-webrootpath}" });
}).LogFactory;
Assert.NotNull(logFactory);
logFactory.Shutdown();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

namespace NLog.Web.Tests.LayoutRenderers
{
public class IISInstanceNameLayoutRendererTests
public class IISInstanceNameLayoutRendererTests : TestBase
{
[Fact]
public void SuccessTest()
Expand Down Expand Up @@ -57,5 +57,16 @@ public void NullTest()

Assert.Equal(string.Empty, actual);
}

[Fact]
public void InitCloseTest()
{
var logFactory = new LogFactory().Setup().RegisterNLogWeb().LoadConfiguration(builder =>
{
builder.ForTarget().WriteTo(new NLog.Targets.MemoryTarget() { Layout = "${iis-site-name}" });
}).LogFactory;
Assert.NotNull(logFactory);
logFactory.Shutdown();
}
}
}

0 comments on commit 9b5b7db

Please sign in to comment.