Skip to content
This repository has been archived by the owner on Jan 8, 2023. It is now read-only.

Commit

Permalink
Added Support for ios and wp81
Browse files Browse the repository at this point in the history
  • Loading branch information
epsmae committed Oct 20, 2016
1 parent a3554fb commit 8f894a4
Show file tree
Hide file tree
Showing 13 changed files with 12,226 additions and 10,851 deletions.
11,887 changes: 6,464 additions & 5,423 deletions src/runner/nunit.runner.uwp/project.lock.json

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions src/runner/nunit.runner/Services/TestOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ namespace NUnit.Runner.Services
/// </summary>
public class TestOptions
{
const string OutputFolderName = "NUnitTestOutput";
const string OutputXmlReportName = "TestResults.xml";

private string _resultFilePath;
Expand All @@ -40,7 +39,7 @@ public class TestOptions
/// </summary>
public TestOptions()
{
_resultFilePath = System.IO.Path.Combine(FileSystem.Current.LocalStorage.Path, OutputFolderName, OutputXmlReportName);
_resultFilePath = System.IO.Path.Combine(FileSystem.Current.LocalStorage.Path, OutputXmlReportName);
}

/// <summary>
Expand Down
38 changes: 26 additions & 12 deletions src/runner/nunit.runner/Services/XmlFileProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,20 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Threading.Tasks;

using NUnit.Framework.Interfaces;

using PCLStorage;

using CreationCollisionOption = PCLStorage.CreationCollisionOption;
using FileAccess = PCLStorage.FileAccess;

namespace NUnit.Runner.Services
{
class XmlFileProcessor : TestResultProcessor
{
public XmlFileProcessor(TestOptions options)
: base(options)
{
}
: base(options) { }

public override async Task Process(ITestResult testResult)
{
Expand Down Expand Up @@ -69,8 +67,11 @@ async Task WriteXmlResultFile(ITestResult testResult)

await CreateFolderRecursive(outputFolderName);

IFolder outputFolder = new FileSystemFolder(outputFolderName);
IFile xmlResultFile = await outputFolder.CreateFileAsync(outputXmlReportName, CreationCollisionOption.ReplaceExisting);
IFolder outputFolder =
await FileSystem.Current.GetFolderFromPathAsync(outputFolderName, CancellationToken.None);

IFile xmlResultFile =
await outputFolder.CreateFileAsync(outputXmlReportName, CreationCollisionOption.ReplaceExisting);
using (var resultFileStream = new StreamWriter(await xmlResultFile.OpenAsync(FileAccess.ReadAndWrite)))
{
string xmlString = testResult.ToXml(true).OuterXml;
Expand All @@ -92,13 +93,26 @@ private static async Task CreateFolderRecursive(string folderPath)

for (int i = 0; i < segments.Length - 1; i++)
{
IFolder folder = new FileSystemFolder(path);

var res = await folder.CheckExistsAsync(segments[i + 1]);
if (res != ExistenceCheckResult.FolderExists)
try
{
await folder.CreateFolderAsync(segments[i + 1], CreationCollisionOption.OpenIfExists);
#if __DROID__
IFolder folder = await FileSystem.Current.GetFolderFromPathAsync(path, CancellationToken.None);
#elif __IOS__
IFolder folder = await FileSystem.Current.GetFolderFromPathAsync(path, CancellationToken.None);
#else
IFolder folder = await FileSystem.Current.GetFolderFromPathAsync(path.Replace('/', '\\'), CancellationToken.None);
#endif
var res = await folder.CheckExistsAsync(segments[i + 1]);
if (res != ExistenceCheckResult.FolderExists)
{
await folder.CreateFolderAsync(segments[i + 1], CreationCollisionOption.OpenIfExists);
}
}
catch (Exception)
{
// ignore
}

path = Path.Combine(path, segments[i + 1]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/tests/nunit.runner.tests.Droid/MainActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected override void OnCreate(Bundle savedInstanceState)
CreateXmlResultFile = true,

// Choose a diffrent path for the xml result file
// ResultFilePath = Path.Combine(Environment.ExternalStorageDirectory.Path, Environment.DirectoryDownloads, "Nunit", "Results.xml")
ResultFilePath = Path.Combine(Environment.ExternalStorageDirectory.Path, Environment.DirectoryDownloads, "Nunit_123", "Results.xml")
};

LoadApplication(nunit);
Expand Down
7 changes: 6 additions & 1 deletion src/tests/nunit.runner.tests.iOS/AppDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ***********************************************************************

using System;
using System.IO;
using Foundation;

using NUnit.Runner.Services;
Expand Down Expand Up @@ -64,7 +66,10 @@ public override bool FinishedLaunching(UIApplication app, NSDictionary options)
//TcpWriterParameters = new TcpWriterInfo("192.168.0.108", 13000),

// Creates a NUnit Xml result file on the host file system using PCLStorage library.
CreateXmlResultFile = false
CreateXmlResultFile = true,

// Choose a diffrent path for the xml result file (ios file share / library directory)
ResultFilePath = Path.Combine(NSFileManager.DefaultManager.GetUrls(NSSearchPathDirectory.LibraryDirectory, NSSearchPathDomain.User)[0].Path, "Results.xml")
};

LoadApplication(nunit);
Expand Down
6 changes: 2 additions & 4 deletions src/tests/nunit.runner.tests.iOS/Entitlements.plist
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
</dict>
<dict/>
</plist>

102 changes: 53 additions & 49 deletions src/tests/nunit.runner.tests.iOS/Info.plist
Original file line number Diff line number Diff line change
@@ -1,52 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>MinimumOSVersion</key>
<string>6.0</string>
<key>CFBundleDisplayName</key>
<string>nunit.runner</string>
<key>CFBundleIdentifier</key>
<string>com.yourcompany.nunit.runner</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>CFBundleIconFiles</key>
<array>
<string>Icon-60@2x</string>
<string>Icon-60@3x</string>
<string>Icon-76</string>
<string>Icon-76@2x</string>
<string>Default</string>
<string>Default@2x</string>
<string>Default-568h@2x</string>
<string>Default-Portrait</string>
<string>Default-Portrait@2x</string>
<string>Icon-Small-40</string>
<string>Icon-Small-40@2x</string>
<string>Icon-Small-40@3x</string>
<string>Icon-Small</string>
<string>Icon-Small@2x</string>
<string>Icon-Small@3x</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
</dict>
<dict>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>MinimumOSVersion</key>
<string>6.0</string>
<key>CFBundleDisplayName</key>
<string>nunit.runner</string>
<key>CFBundleIdentifier</key>
<string>com.yourcompany.nunit.runner</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>CFBundleIconFiles</key>
<array>
<string>Icon-60@2x</string>
<string>Icon-60@3x</string>
<string>Icon-76</string>
<string>Icon-76@2x</string>
<string>Default</string>
<string>Default@2x</string>
<string>Default-568h@2x</string>
<string>Default-Portrait</string>
<string>Default-Portrait@2x</string>
<string>Icon-Small-40</string>
<string>Icon-Small-40@2x</string>
<string>Icon-Small-40@3x</string>
<string>Icon-Small</string>
<string>Icon-Small@2x</string>
<string>Icon-Small@3x</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>CFBundleShortVersionString</key>
<string></string>
<key>UIFileSharingEnabled</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
<MtouchLink>None</MtouchLink>
<MtouchDebug>true</MtouchDebug>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<CodesignKey>iPhone Developer: Christian Schmid (R65G567HMV)</CodesignKey>
<CodesignProvision>dccfb495-a21d-4e42-8f9b-09f3126395e5</CodesignProvision>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
<DebugType>none</DebugType>
Expand All @@ -47,9 +49,10 @@
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<MtouchArch>ARMv7, ARM64</MtouchArch>
<CodesignKey>iPhone Developer</CodesignKey>
<CodesignKey>iPhone Developer: Christian Schmid (R65G567HMV)</CodesignKey>
<MtouchDebug>true</MtouchDebug>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<CodesignProvision>dccfb495-a21d-4e42-8f9b-09f3126395e5</CodesignProvision>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
<DebugType>none</DebugType>
Expand Down Expand Up @@ -91,7 +94,9 @@
<Compile Include="Main.cs" />
<Compile Include="AppDelegate.cs" />
<None Include="Entitlements.plist" />
<None Include="Info.plist" />
<None Include="Info.plist">
<SubType>Designer</SubType>
</None>
<Compile Include="Properties\AssemblyInfo.cs" />
<ITunesArtwork Include="iTunesArtwork" />
<None Include="packages.config" />
Expand Down
6 changes: 5 additions & 1 deletion src/tests/nunit.runner.tests.uwp/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ public MainPage()
//TcpWriterParameters = new TcpWriterInfo("192.168.0.108", 13000),

// Creates a NUnit Xml result file on the host file system using PCLStorage library.
CreateXmlResultFile = false
CreateXmlResultFile = false,

// Choose a diffrent path for the xml result file
// Windows phone 8.1 no permission to create subfolder in Windows.Storage.ApplicationData.Current.LocalFolder
// ResultFilePath = System.IO.Path.Combine(Windows.Storage.ApplicationData.Current.TemporaryFolder.Path, "Nunit", "Results.xml")
};

LoadApplication(nunit);
Expand Down
1 change: 1 addition & 0 deletions src/tests/nunit.runner.tests.uwp/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
<Capabilities>
<Capability Name="internetClient" />
<Capability Name="privateNetworkClientServer" />
<uap:Capability Name="removableStorage" />
</Capabilities>
</Package>
Loading

0 comments on commit 8f894a4

Please sign in to comment.