Permalink
Browse files

Added additional tests for [ThreadAgnostic]

  • Loading branch information...
jkowalski committed Jul 15, 2011
1 parent 871ca9f commit 29416d6cd92c53bb996faa4417fb118517703288
Showing with 44 additions and 0 deletions.
  1. +44 −0 tests/NLog.UnitTests/Layouts/ThreadAgnosticTests.cs
@@ -47,6 +47,7 @@ namespace NLog.UnitTests.Layouts
using TestFixture = Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute;
using Test = Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute;
using TearDown = Microsoft.VisualStudio.TestTools.UnitTesting.TestCleanupAttribute;
+ using NLog.LayoutRenderers;
#endif
[TestFixture]
@@ -183,5 +184,48 @@ public void CsvNonAgnostic()
l.Initialize(null);
Assert.IsFalse(l.IsThreadAgnostic);
}
+
+ [Test]
+ public void CustomNotAgnosticTests()
+ {
+ var cif = new ConfigurationItemFactory();
+ cif.RegisterType(typeof(CustomRendererNonAgnostic), string.Empty);
+
+ Layout l = new SimpleLayout("${customNotAgnostic}", cif);
+
+ l.Initialize(null);
+ Assert.IsFalse(l.IsThreadAgnostic);
+ }
+
+ [Test]
+ public void CustomAgnosticTests()
+ {
+ var cif = new ConfigurationItemFactory();
+ cif.RegisterType(typeof(CustomRendererAgnostic), string.Empty);
+
+ Layout l = new SimpleLayout("${customAgnostic}", cif);
+
+ l.Initialize(null);
+ Assert.IsTrue(l.IsThreadAgnostic);
+ }
+
+ [LayoutRenderer("customNotAgnostic")]
+ public class CustomRendererNonAgnostic : LayoutRenderer
+ {
+ protected override void Append(System.Text.StringBuilder builder, LogEventInfo logEvent)
+ {
+ builder.Append("custom");
+ }
+ }
+
+ [LayoutRenderer("customAgnostic")]
+ [ThreadAgnostic]
+ public class CustomRendererAgnostic : LayoutRenderer
+ {
+ protected override void Append(System.Text.StringBuilder builder, LogEventInfo logEvent)
+ {
+ builder.Append("customAgnostic");
+ }
+ }
}
}

0 comments on commit 29416d6

Please sign in to comment.