Skip to content

Commit

Permalink
Windows Phone 7.1 unit test support
Browse files Browse the repository at this point in the history
  • Loading branch information
jkowalski committed Jun 9, 2011
1 parent b01245a commit 2a89386
Show file tree
Hide file tree
Showing 31 changed files with 422 additions and 232 deletions.
11 changes: 11 additions & 0 deletions external/SilverlightUnitTestFramework/WP71/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
MSDN CODE GALLERY BINARY LICENSE

You are free to install, use, copy and distribute any number of copies of the software, in object code form, provided that you retain:

� all copyright, patent, trademark, and attribution notices that are present in the software,
� this list of conditions, and
� the following disclaimer in the documentation and/or other materials provided with the software.

The software is licensed �as-is.� You bear the risk of using it. No express warranties, guarantees or conditions are provided. To the extent permitted under your local laws, the implied warranties of merchantability, fitness for a particular purpose and non-infringement are excluded.

This license does not grant you any rights to use any other party�s name, logo, or trademarks. All rights not specifically granted herein are reserved.
Binary file not shown.
Binary file not shown.
12 changes: 12 additions & 0 deletions src/NLog.proj
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@
<CallTarget Targets="SL2Test" Condition="'$(BuildSL2)'=='true'"/>
<CallTarget Targets="SL3Test" Condition="'$(BuildSL3)'=='true'"/>
<CallTarget Targets="SL4Test" Condition="'$(BuildSL4)'=='true'"/>
<CallTarget Targets="WP7Test" Condition="'$(BuildWP7)'=='true'"/>
<CallTarget Targets="WP71Test" Condition="'$(BuildWP71)'=='true'"/>
<CallTarget Targets="RunComApiTests" />
<Exec Command="..\tests\DeleteTestUsers.cmd" IgnoreExitCode="true" />
</Target>
Expand Down Expand Up @@ -334,6 +336,16 @@
WorkingDirectory="$(BaseOutputDirectory)\bin\$(Configuration)\Silverlight 4.0" IgnoreExitCode="true" />
</Target>

<Target Name="WP7Test" DependsOnTargets="BuildSLTestRunner">
<Exec Command='"$(SLTestRunner)" NLog.UnitTests.xap WP7 -guid 3cf9fab9-588c-49c8-8a45-ef071442304f -icon ApplicationIcon.png'
WorkingDirectory="$(BaseOutputDirectory)\bin\$(Configuration)\Silverlight for Windows Phone 7" IgnoreExitCode="true" />
</Target>

<Target Name="WP71Test" DependsOnTargets="BuildSLTestRunner">
<Exec Command='"$(SLTestRunner)" NLog.UnitTests.xap WP71 -guid 3cf9fab9-588c-49c8-8a45-ef071442304f -icon ApplicationIcon.png'
WorkingDirectory="$(BaseOutputDirectory)\bin\$(Configuration)\Silverlight for Windows Phone 7.1" IgnoreExitCode="true" />
</Target>

<Target Name="CheckinSuite">
<CallTarget Targets="SyncProjectItems" />
<CallTarget Targets="DeepClean" />
Expand Down
8 changes: 0 additions & 8 deletions src/NLog.wp71.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLog.UnitTests.wp71", "..\t
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleExtensions.wp71", "..\tests\SampleExtensions\SampleExtensions.wp71.csproj", "{8A0E38D3-1512-45B0-A360-218F7E98743D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLogWindowsPhoneApplication", "..\examples\NLogWindowsPhoneApplication\NLogWindowsPhoneApplication.csproj", "{17F2F126-6945-48A0-900F-A0859A3F1A0D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -28,12 +26,6 @@ Global
{8A0E38D3-1512-45B0-A360-218F7E98743D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8A0E38D3-1512-45B0-A360-218F7E98743D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8A0E38D3-1512-45B0-A360-218F7E98743D}.Release|Any CPU.Build.0 = Release|Any CPU
{17F2F126-6945-48A0-900F-A0859A3F1A0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{17F2F126-6945-48A0-900F-A0859A3F1A0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{17F2F126-6945-48A0-900F-A0859A3F1A0D}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{17F2F126-6945-48A0-900F-A0859A3F1A0D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{17F2F126-6945-48A0-900F-A0859A3F1A0D}.Release|Any CPU.Build.0 = Release|Any CPU
{17F2F126-6945-48A0-900F-A0859A3F1A0D}.Release|Any CPU.Deploy.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
64 changes: 42 additions & 22 deletions tests/NLog.UnitTests/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,15 @@

namespace NLog.UnitTests
{
using System.Net;
using System.Text;
using System.Xml.Linq;
using Microsoft.Silverlight.Testing.UnitTesting.Metadata.VisualStudio;

public partial class App : Application
{
private VisualStudioLogProvider vsProvider = new VisualStudioLogProvider();
private static Uri baseUrl = new Uri("http://localhost:17788");

public App()
{
Expand All @@ -63,17 +69,41 @@ class MyLogProvider : LogProvider
{
public override void Process(LogMessage logMessage)
{
if (logMessage.HasDecorator(LogDecorator.TestStage))
{
var stage = (TestStage)logMessage[LogDecorator.TestStage];
if (stage == TestStage.Starting)
{
if (logMessage.HasDecorator(UnitTestLogDecorator.TestMethodMetadata))
{
var methodInfo = (TestMethod)logMessage[UnitTestLogDecorator.TestMethodMetadata];
var wc = new WebClient();
wc.UploadStringAsync(new Uri(baseUrl, "/TestMethodStarting?method=" + methodInfo.Name), "");
}
else if (logMessage.HasDecorator(UnitTestLogDecorator.TestClassMetadata))
{
var classInfo = (TestClass)logMessage[UnitTestLogDecorator.TestClassMetadata];
var wc = new WebClient();
wc.UploadStringAsync(new Uri(baseUrl, "/TestClassStarting?class=" + classInfo.Type.FullName), "");
}
}
}

if (logMessage.HasDecorator(UnitTestLogDecorator.ScenarioResult))
{
var result = (ScenarioResult)logMessage[UnitTestLogDecorator.ScenarioResult];

InvokeDomMethod("scenarioResult",
result.Started.Ticks,
result.Finished.Ticks,
(result.TestClass != null) ? result.TestClass.Type.FullName : null,
(result.TestMethod != null) ? result.TestMethod.Name : null,
result.Result.ToString(),
(result.Exception != null) ? result.Exception.ToString() : null);
var wc = new WebClient();
StringBuilder uri = new StringBuilder();
uri.Append("/TestMethodCompleted?result=" + result.Result);
if (result.TestClass != null)
{
uri.Append("&class=").Append(result.TestClass.Type.FullName);
}
if (result.TestMethod != null)
{
uri.Append("&method=").Append(result.TestMethod.Name);
}
wc.UploadStringAsync(new Uri(baseUrl, uri.ToString()), "");
}
}
}
Expand Down Expand Up @@ -106,7 +136,9 @@ void TestHarness_TestHarnessCompleted(object sender, TestHarnessCompletedEventAr
var harness = new MyHarness();

vsProvider.WriteLogFile(harness);
InvokeDomMethod("testCompleted", harness.TrxContent);

var wc = new WebClient();
wc.UploadStringAsync(new Uri(baseUrl, "/Completed"), harness.TrxContent);
}

private void Application_Exit(object sender, EventArgs e)
Expand All @@ -115,6 +147,7 @@ private void Application_Exit(object sender, EventArgs e)

private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
{
MessageBox.Show(e.ExceptionObject.ToString());
// If the app is running outside of the debugger then report the exception using
// the browser's exception mechanism. On IE this will display it a yellow alert
// icon in the status bar and Firefox will display a script error.
Expand Down Expand Up @@ -147,19 +180,6 @@ private void ReportErrorToDOM(ApplicationUnhandledExceptionEventArgs e)
{
}
}

private static void InvokeDomMethod(string methodName, params object[] arguments)
{
try
{
#if !WINDOWS_PHONE
HtmlPage.Window.Invoke(methodName, arguments);
#endif
}
catch
{
}
}
}
}

Expand Down
3 changes: 0 additions & 3 deletions tests/NLog.UnitTests/NLog.UnitTests.monodevelop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@
<Compile Include="Targets\Wrappers\WrapperTargetBaseTests.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="ApplicationIcon.png" />
<Content Include="Background.png" />
<Content Include="ConfigFiles\included.nlog" />
<Content Include="ConfigFiles\main.nlog" />
<Content Include="ConfigFiles\referencemissingfile.nlog" />
Expand All @@ -166,7 +164,6 @@
<Content Include="Properties\AppManifest.xml" />
<Content Include="Properties\OutOfBrowserSettings.xml" />
<Content Include="Properties\WMAppManifest.xml" />
<Content Include="SplashScreenImage.jpg" />
</ItemGroup>
<ItemGroup>
<None Include="NLogTests.snk" />
Expand Down
3 changes: 0 additions & 3 deletions tests/NLog.UnitTests/NLog.UnitTests.netcf20.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,6 @@
<None Include="NLogTests.snk" />
</ItemGroup>
<ItemGroup>
<Content Include="ApplicationIcon.png" />
<Content Include="Background.png" />
<Content Include="ConfigFiles\included.nlog" />
<Content Include="ConfigFiles\main.nlog" />
<Content Include="ConfigFiles\referencemissingfile.nlog" />
Expand All @@ -175,7 +173,6 @@
<Content Include="Properties\AppManifest.xml" />
<Content Include="Properties\OutOfBrowserSettings.xml" />
<Content Include="Properties\WMAppManifest.xml" />
<Content Include="SplashScreenImage.jpg" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\NLog\NLog.netcf20.csproj">
Expand Down
3 changes: 0 additions & 3 deletions tests/NLog.UnitTests/NLog.UnitTests.netcf35.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,6 @@
<Compile Include="Targets\Wrappers\WrapperTargetBaseTests.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="ApplicationIcon.png" />
<Content Include="Background.png" />
<Content Include="ConfigFiles\included.nlog" />
<Content Include="ConfigFiles\main.nlog" />
<Content Include="ConfigFiles\referencemissingfile.nlog" />
Expand All @@ -170,7 +168,6 @@
<Content Include="Properties\AppManifest.xml" />
<Content Include="Properties\OutOfBrowserSettings.xml" />
<Content Include="Properties\WMAppManifest.xml" />
<Content Include="SplashScreenImage.jpg" />
</ItemGroup>
<ItemGroup>
<None Include="NLogTests.snk" />
Expand Down
3 changes: 0 additions & 3 deletions tests/NLog.UnitTests/NLog.UnitTests.netfx20.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,6 @@
<Compile Include="Targets\Wrappers\WrapperTargetBaseTests.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="ApplicationIcon.png" />
<Content Include="Background.png" />
<Content Include="ConfigFiles\included.nlog" />
<Content Include="ConfigFiles\main.nlog" />
<Content Include="ConfigFiles\referencemissingfile.nlog" />
Expand All @@ -170,7 +168,6 @@
<Content Include="Properties\AppManifest.xml" />
<Content Include="Properties\OutOfBrowserSettings.xml" />
<Content Include="Properties\WMAppManifest.xml" />
<Content Include="SplashScreenImage.jpg" />
</ItemGroup>
<ItemGroup>
<None Include="NLogTests.snk" />
Expand Down
3 changes: 0 additions & 3 deletions tests/NLog.UnitTests/NLog.UnitTests.netfx35.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,6 @@
<Compile Include="Targets\Wrappers\WrapperTargetBaseTests.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="ApplicationIcon.png" />
<Content Include="Background.png" />
<Content Include="ConfigFiles\included.nlog" />
<Content Include="ConfigFiles\main.nlog" />
<Content Include="ConfigFiles\referencemissingfile.nlog" />
Expand All @@ -172,7 +170,6 @@
<Content Include="Properties\AppManifest.xml" />
<Content Include="Properties\OutOfBrowserSettings.xml" />
<Content Include="Properties\WMAppManifest.xml" />
<Content Include="SplashScreenImage.jpg" />
</ItemGroup>
<ItemGroup>
<None Include="NLogTests.snk" />
Expand Down
9 changes: 2 additions & 7 deletions tests/NLog.UnitTests/NLog.UnitTests.netfx40.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<ApplicationIcon>
</ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<ApplicationIcon></ApplicationIcon>
<AssemblyKeyContainerName></AssemblyKeyContainerName>
<AssemblyName>NLog.UnitTests</AssemblyName>
<AssemblyOriginatorKeyFile>NLogTests.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
Expand Down Expand Up @@ -161,8 +159,6 @@
<Compile Include="Targets\Wrappers\WrapperTargetBaseTests.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="ApplicationIcon.png" />
<Content Include="Background.png" />
<Content Include="ConfigFiles\included.nlog" />
<Content Include="ConfigFiles\main.nlog" />
<Content Include="ConfigFiles\referencemissingfile.nlog" />
Expand All @@ -171,7 +167,6 @@
<Content Include="Properties\AppManifest.xml" />
<Content Include="Properties\OutOfBrowserSettings.xml" />
<Content Include="Properties\WMAppManifest.xml" />
<Content Include="SplashScreenImage.jpg" />
</ItemGroup>
<ItemGroup>
<None Include="NLogTests.snk" />
Expand Down
3 changes: 0 additions & 3 deletions tests/NLog.UnitTests/NLog.UnitTests.sl2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@
<None Include="Properties\OutOfBrowserSettings.xml" />
</ItemGroup>
<ItemGroup>
<Content Include="ApplicationIcon.png" />
<Content Include="Background.png" />
<Content Include="ConfigFiles\included.nlog" />
<Content Include="ConfigFiles\main.nlog" />
<Content Include="ConfigFiles\referencemissingfile.nlog" />
Expand All @@ -218,7 +216,6 @@
<Content Include="Properties\AppManifest.xml" />
<Content Include="Properties\OutOfBrowserSettings.xml" />
<Content Include="Properties\WMAppManifest.xml" />
<Content Include="SplashScreenImage.jpg" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\NLog\NLog.sl2.csproj">
Expand Down
3 changes: 0 additions & 3 deletions tests/NLog.UnitTests/NLog.UnitTests.sl3.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,6 @@
<None Include="Properties\OutOfBrowserSettings.xml" />
</ItemGroup>
<ItemGroup>
<Content Include="ApplicationIcon.png" />
<Content Include="Background.png" />
<Content Include="ConfigFiles\included.nlog" />
<Content Include="ConfigFiles\main.nlog" />
<Content Include="ConfigFiles\referencemissingfile.nlog" />
Expand All @@ -206,7 +204,6 @@
<Content Include="Properties\AppManifest.xml" />
<Content Include="Properties\OutOfBrowserSettings.xml" />
<Content Include="Properties\WMAppManifest.xml" />
<Content Include="SplashScreenImage.jpg" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\NLog\NLog.sl3.csproj">
Expand Down
3 changes: 0 additions & 3 deletions tests/NLog.UnitTests/NLog.UnitTests.sl4.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,6 @@
</ApplicationDefinition>
</ItemGroup>
<ItemGroup>
<Content Include="ApplicationIcon.png" />
<Content Include="Background.png" />
<Content Include="ConfigFiles\included.nlog" />
<Content Include="ConfigFiles\main.nlog" />
<Content Include="ConfigFiles\referencemissingfile.nlog" />
Expand All @@ -200,7 +198,6 @@
<Content Include="Properties\AppManifest.xml" />
<Content Include="Properties\OutOfBrowserSettings.xml" />
<Content Include="Properties\WMAppManifest.xml" />
<Content Include="SplashScreenImage.jpg" />
</ItemGroup>
<ItemGroup>
<Content Include="ConfigFiles\included.nlog" />
Expand Down
12 changes: 9 additions & 3 deletions tests/NLog.UnitTests/NLog.UnitTests.wp7.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,12 @@
</ApplicationDefinition>
</ItemGroup>
<ItemGroup>
<Content Include="ApplicationIcon.png" />
<Content Include="Background.png" />
<Content Include="ApplicationIcon.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Background.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="ConfigFiles\included.nlog" />
<Content Include="ConfigFiles\main.nlog" />
<Content Include="ConfigFiles\referencemissingfile.nlog" />
Expand All @@ -192,7 +196,9 @@
<Content Include="Properties\AppManifest.xml" />
<Content Include="Properties\OutOfBrowserSettings.xml" />
<Content Include="Properties\WMAppManifest.xml" />
<Content Include="SplashScreenImage.jpg" />
<Content Include="SplashScreenImage.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="ConfigFiles\included.nlog" />
Expand Down
16 changes: 11 additions & 5 deletions tests/NLog.UnitTests/NLog.UnitTests.wp71.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@
<ItemGroup>
<Reference Include="Microsoft.Silverlight.Testing, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\external\SilverlightUnitTestFramework\WP7\Microsoft.Silverlight.Testing.dll</HintPath>
<HintPath>..\..\external\SilverlightUnitTestFramework\WP71\Microsoft.Silverlight.Testing.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\external\SilverlightUnitTestFramework\WP7\Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll</HintPath>
<HintPath>..\..\external\SilverlightUnitTestFramework\WP71\Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll</HintPath>
</Reference>
<Reference Include="System.Windows" />
<Reference Include="mscorlib" />
Expand Down Expand Up @@ -182,8 +182,12 @@
</ApplicationDefinition>
</ItemGroup>
<ItemGroup>
<Content Include="ApplicationIcon.png" />
<Content Include="Background.png" />
<Content Include="ApplicationIcon.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Background.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="ConfigFiles\included.nlog" />
<Content Include="ConfigFiles\main.nlog" />
<Content Include="ConfigFiles\referencemissingfile.nlog" />
Expand All @@ -192,7 +196,9 @@
<Content Include="Properties\AppManifest.xml" />
<Content Include="Properties\OutOfBrowserSettings.xml" />
<Content Include="Properties\WMAppManifest.xml" />
<Content Include="SplashScreenImage.jpg" />
<Content Include="SplashScreenImage.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="ConfigFiles\included.nlog" />
Expand Down
Loading

0 comments on commit 2a89386

Please sign in to comment.