Permalink
Browse files

Added tests for <extensions /> for .NET, SL and CF

Added SampleExtensions project
Fixed <variable /> handling for all platforms and added unit tests.
  • Loading branch information...
1 parent 0318728 commit 17e016b7a6adaa3d72604b826fab5b6143c0c728 @jkowalski jkowalski committed Jun 22, 2010
Showing with 1,467 additions and 52 deletions.
  1. +6 −0 src/NLog.netcf20.sln
  2. +6 −0 src/NLog.netcf35.sln
  3. +6 −0 src/NLog.netfx20.sln
  4. +6 −0 src/NLog.netfx35.sln
  5. +6 −0 src/NLog.netfx40.sln
  6. +1 −0 src/NLog.proj
  7. +32 −0 src/NLog.sl2.sln
  8. +6 −0 src/NLog.sl3.vs2008.sln
  9. +6 −0 src/NLog.sl4.sln
  10. +19 −2 src/NLog/Config/XmlLoggingConfiguration.cs
  11. +190 −0 tests/NLog.UnitTests/Config/ExtensionTests.cs
  12. +72 −0 tests/NLog.UnitTests/Config/VariableTests.cs
  13. +8 −1 tests/NLog.UnitTests/NLog.UnitTests.netcf20.csproj
  14. +8 −1 tests/NLog.UnitTests/NLog.UnitTests.netcf35.csproj
  15. +10 −2 tests/NLog.UnitTests/NLog.UnitTests.netfx20.csproj
  16. +10 −2 tests/NLog.UnitTests/NLog.UnitTests.netfx35.csproj
  17. +10 −3 tests/NLog.UnitTests/NLog.UnitTests.netfx40.csproj
  18. +14 −36 tests/NLog.UnitTests/NLog.UnitTests.sl2.csproj
  19. +10 −2 tests/NLog.UnitTests/NLog.UnitTests.sl3.csproj
  20. +10 −2 tests/NLog.UnitTests/NLog.UnitTests.sl4.csproj
  21. +8 −1 tests/NLog.UnitTests/NLogTestBase.cs
  22. +55 −0 tests/SampleExtensions/FooLayout.cs
  23. +49 −0 tests/SampleExtensions/FooLayoutRenderer.cs
  24. +49 −0 tests/SampleExtensions/MyConditionMethods.cs
  25. +47 −0 tests/SampleExtensions/MyTarget.cs
  26. BIN tests/SampleExtensions/NLogTests.snk
  27. +60 −0 tests/SampleExtensions/ProjectFileInfo.xml
  28. +88 −0 tests/SampleExtensions/SampleExtensions.netcf20.csproj
  29. +85 −0 tests/SampleExtensions/SampleExtensions.netcf35.csproj
  30. +74 −0 tests/SampleExtensions/SampleExtensions.netfx20.csproj
  31. +78 −0 tests/SampleExtensions/SampleExtensions.netfx35.csproj
  32. +74 −0 tests/SampleExtensions/SampleExtensions.netfx40.csproj
  33. +92 −0 tests/SampleExtensions/SampleExtensions.sl2.csproj
  34. +106 −0 tests/SampleExtensions/SampleExtensions.sl3.csproj
  35. +106 −0 tests/SampleExtensions/SampleExtensions.sl4.csproj
  36. +60 −0 tests/SampleExtensions/WhenFooFilter.cs
View
@@ -10,6 +10,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLog.netcf20", "NLog\NLog.n
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLog.UnitTests.netcf20", "..\tests\NLog.UnitTests\NLog.UnitTests.netcf20.csproj", "{C6558721-BA0E-488A-AE61-87D46BEF0E16}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleExtensions.netcf20", "..\tests\SampleExtensions\SampleExtensions.netcf20.csproj", "{C6558721-BA0E-488A-AE61-87D46BEF1E16}"
+EndProject
Global
GlobalSection(TestCaseManagementSettings) = postSolution
CategoryFile = NLog.netcf20.vsmdi
@@ -27,6 +29,10 @@ Global
{C6558721-BA0E-488A-AE61-87D46BEF0E16}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C6558721-BA0E-488A-AE61-87D46BEF0E16}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C6558721-BA0E-488A-AE61-87D46BEF0E16}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C6558721-BA0E-488A-AE61-87D46BEF1E16}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C6558721-BA0E-488A-AE61-87D46BEF1E16}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C6558721-BA0E-488A-AE61-87D46BEF1E16}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C6558721-BA0E-488A-AE61-87D46BEF1E16}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
View
@@ -10,6 +10,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLog.netcf35", "NLog\NLog.n
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLog.UnitTests.netcf35", "..\tests\NLog.UnitTests\NLog.UnitTests.netcf35.csproj", "{2A1AFF0C-0C26-4B2E-95C5-BCFBBE347031}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleExtensions.netcf35", "..\tests\SampleExtensions\SampleExtensions.netcf35.csproj", "{2A1AFF0C-0C26-4B2E-95C5-BCFBBE343031}"
+EndProject
Global
GlobalSection(TestCaseManagementSettings) = postSolution
CategoryFile = NLog.netcf35.vsmdi
@@ -27,6 +29,10 @@ Global
{2A1AFF0C-0C26-4B2E-95C5-BCFBBE347031}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2A1AFF0C-0C26-4B2E-95C5-BCFBBE347031}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2A1AFF0C-0C26-4B2E-95C5-BCFBBE347031}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2A1AFF0C-0C26-4B2E-95C5-BCFBBE343031}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2A1AFF0C-0C26-4B2E-95C5-BCFBBE343031}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2A1AFF0C-0C26-4B2E-95C5-BCFBBE343031}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2A1AFF0C-0C26-4B2E-95C5-BCFBBE343031}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
View
@@ -10,6 +10,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLog.netfx20", "NLog\NLog.n
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLog.UnitTests.netfx20", "..\tests\NLog.UnitTests\NLog.UnitTests.netfx20.csproj", "{1653EE05-2720-4A85-BF14-74C4493787B1}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleExtensions.netfx20", "..\tests\SampleExtensions\SampleExtensions.netfx20.csproj", "{1653EE05-2720-4A85-BF14-74C4593787B1}"
+EndProject
Global
GlobalSection(TestCaseManagementSettings) = postSolution
CategoryFile = NLog.netfx20.vsmdi
@@ -27,6 +29,10 @@ Global
{1653EE05-2720-4A85-BF14-74C4493787B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1653EE05-2720-4A85-BF14-74C4493787B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1653EE05-2720-4A85-BF14-74C4493787B1}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1653EE05-2720-4A85-BF14-74C4593787B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1653EE05-2720-4A85-BF14-74C4593787B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1653EE05-2720-4A85-BF14-74C4593787B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1653EE05-2720-4A85-BF14-74C4593787B1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
View
@@ -16,6 +16,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLog.Test", "..\tests\NLog.
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLog.BinaryCompatTests.netfx35", "..\tests\NLog.BinaryCompatTests\NLog.BinaryCompatTests.netfx35.csproj", "{157588EF-6665-468C-B860-B90B71A5E7FB}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleExtensions.netfx35", "..\tests\SampleExtensions\SampleExtensions.netfx35.csproj", "{A8CA32F1-BD4C-4A99-B307-99A93DB64B9F}"
+EndProject
Global
GlobalSection(TestCaseManagementSettings) = postSolution
CategoryFile = NLog.netfx35.vsmdi
@@ -45,6 +47,10 @@ Global
{157588EF-6665-468C-B860-B90B71A5E7FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{157588EF-6665-468C-B860-B90B71A5E7FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{157588EF-6665-468C-B860-B90B71A5E7FB}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A8CA32F1-BD4C-4A99-B307-99A93DB64B9F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A8CA32F1-BD4C-4A99-B307-99A93DB64B9F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A8CA32F1-BD4C-4A99-B307-99A93DB64B9F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A8CA32F1-BD4C-4A99-B307-99A93DB64B9F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
View
@@ -12,6 +12,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLog.UnitTests.netfx40", ".
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLog.Extended.netfx40", "NLog\NLog.Extended.netfx40.csproj", "{A961A1F9-1024-4446-BF9E-A923137340B8}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleExtensions.netfx40", "..\tests\SampleExtensions\SampleExtensions.netfx40.csproj", "{FE067913-E9A8-41F0-89FA-C1136F8FB6A8}"
+EndProject
Global
GlobalSection(TestCaseManagementSettings) = postSolution
CategoryFile = NLog.netfx40.vsmdi
@@ -33,6 +35,10 @@ Global
{A961A1F9-1024-4446-BF9E-A923137340B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A961A1F9-1024-4446-BF9E-A923137340B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A961A1F9-1024-4446-BF9E-A923137340B8}.Release|Any CPU.Build.0 = Release|Any CPU
+ {FE067913-E9A8-41F0-89FA-C1136F8FB6A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {FE067913-E9A8-41F0-89FA-C1136F8FB6A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {FE067913-E9A8-41F0-89FA-C1136F8FB6A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {FE067913-E9A8-41F0-89FA-C1136F8FB6A8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
View
@@ -360,6 +360,7 @@
<Target Name="SyncProjectItems" DependsOnTargets="BuildSyncProjectItemsTool">
<Exec Command='"$(SyncProjectItems)" ProjectFileInfo.xml' WorkingDirectory="NLog" />
<Exec Command='"$(SyncProjectItems)" ProjectFileInfo.xml' WorkingDirectory="..\Tests\NLog.UnitTests" />
+ <Exec Command='"$(SyncProjectItems)" ProjectFileInfo.xml' WorkingDirectory="..\Tests\SampleExtensions" />
</Target>
<Target Name="BuildApiDumpTool">
View
@@ -0,0 +1,32 @@
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLog.UnitTests.sl2", "..\tests\NLog.UnitTests\NLog.UnitTests.sl2.csproj", "{D172C49A-55C9-47B3-B1F7-40D5AB64E8E8}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLog.sl2", "NLog\NLog.sl2.csproj", "{0D90976A-D1FD-4FEF-B7A9-9A40731C19EB}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleExtensions.sl2", "..\tests\SampleExtensions\SampleExtensions.sl2.csproj", "{D172C49A-55C9-47B3-B3F7-40D5AB64E8E8}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {D172C49A-55C9-47B3-B1F7-40D5AB64E8E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D172C49A-55C9-47B3-B1F7-40D5AB64E8E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D172C49A-55C9-47B3-B1F7-40D5AB64E8E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D172C49A-55C9-47B3-B1F7-40D5AB64E8E8}.Release|Any CPU.Build.0 = Release|Any CPU
+ {0D90976A-D1FD-4FEF-B7A9-9A40731C19EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {0D90976A-D1FD-4FEF-B7A9-9A40731C19EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {0D90976A-D1FD-4FEF-B7A9-9A40731C19EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {0D90976A-D1FD-4FEF-B7A9-9A40731C19EB}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D172C49A-55C9-47B3-B3F7-40D5AB64E8E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D172C49A-55C9-47B3-B3F7-40D5AB64E8E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D172C49A-55C9-47B3-B3F7-40D5AB64E8E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D172C49A-55C9-47B3-B3F7-40D5AB64E8E8}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
View
@@ -6,6 +6,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLog.sl3", "NLog\NLog.sl3.c
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLog.UnitTests.sl3", "..\tests\NLog.UnitTests\NLog.UnitTests.sl3.csproj", "{C48047FF-7E14-443D-906D-7E021AB5707A}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleExtensions.sl3", "..\tests\SampleExtensions\SampleExtensions.sl3.csproj", "{C48047FF-7E14-443D-906D-7E021AB5307A}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -24,6 +26,10 @@ Global
{C48047FF-7E14-443D-906D-7E021AB5707A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C48047FF-7E14-443D-906D-7E021AB5707A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C48047FF-7E14-443D-906D-7E021AB5707A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C48047FF-7E14-443D-906D-7E021AB5307A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C48047FF-7E14-443D-906D-7E021AB5307A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C48047FF-7E14-443D-906D-7E021AB5307A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C48047FF-7E14-443D-906D-7E021AB5307A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
View
@@ -6,6 +6,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLog.sl4", "NLog\NLog.sl4.c
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLog.UnitTests.sl4", "..\tests\NLog.UnitTests\NLog.UnitTests.sl4.csproj", "{C48047FF-7E14-443D-906D-7E021AB5707A}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleExtensions.sl4", "..\tests\SampleExtensions\SampleExtensions.sl4.csproj", "{C480452F-7E14-443D-906D-7E021AB5707A}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -24,6 +26,10 @@ Global
{C48047FF-7E14-443D-906D-7E021AB5707A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C48047FF-7E14-443D-906D-7E021AB5707A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C48047FF-7E14-443D-906D-7E021AB5707A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C480452F-7E14-443D-906D-7E021AB5707A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C480452F-7E14-443D-906D-7E021AB5707A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C480452F-7E14-443D-906D-7E021AB5707A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C480452F-7E14-443D-906D-7E021AB5707A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -40,6 +40,7 @@ namespace NLog.Config
using System.Globalization;
using System.IO;
using System.Reflection;
+ using System.Windows;
using System.Xml;
using NLog.Common;
using NLog.Filters;
@@ -477,7 +478,10 @@ private void ParseFilters(LoggingRule rule, XmlReader reader)
private void ParseVariableElement(XmlReader reader)
{
- reader.Skip();
+ string name = reader.GetAttribute("name");
+ string value = reader.GetAttribute("value");
+
+ this.variables[name] = value;
}
private string GetCaseInsensitiveAttribute(XmlReader reader, string attributeName, string defaultValue)
@@ -735,10 +739,17 @@ private void ParseExtensionsElement(XmlReader reader, string baseDirectory)
{
try
{
+#if SILVERLIGHT
+ var si = Application.GetResourceStream(new Uri(assemblyFile, UriKind.Relative));
+ var assemblyPart = new AssemblyPart();
+ Assembly asm = assemblyPart.Load(si.Stream);
+#else
+
string fullFileName = Path.Combine(baseDirectory, assemblyFile);
InternalLogger.Info("Loading assemblyFile: {0}", fullFileName);
- Assembly asm = Assembly.LoadFrom(fullFileName);
+ Assembly asm = Assembly.LoadFrom(fullFileName);
+#endif
this.nlogFactories.RegisterItemsFromAssembly(asm, prefix);
}
catch (Exception ex)
@@ -759,7 +770,13 @@ private void ParseExtensionsElement(XmlReader reader, string baseDirectory)
try
{
InternalLogger.Info("Loading assemblyName: {0}", assemblyName);
+#if SILVERLIGHT
+ var si = Application.GetResourceStream(new Uri(assemblyName + ".dll", UriKind.Relative));
+ var assemblyPart = new AssemblyPart();
+ Assembly asm = assemblyPart.Load(si.Stream);
+#else
Assembly asm = Assembly.Load(assemblyName);
+#endif
this.nlogFactories.RegisterItemsFromAssembly(asm, prefix);
}
Oops, something went wrong.

0 comments on commit 17e016b

Please sign in to comment.