diff --git a/README.md b/README.md index 8e29907..82d99e9 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ NUnit test runners for Xamarin and mobile devices ## How to Use ## -Project templates will be coming soon, in the meantime... +**Project templates will be coming soon**, in the meantime... In your solution; @@ -12,13 +12,15 @@ In your solution; - `Blank App (Android)` for Android, - `Blank App (iOS)` for iOS, - `Blank App (Windows Phone)` for Windows Phone 8.1 + - `Blank App (Universal Windows)` for Windows 10 Universal 2. Add the `nunit.xamarin` NuGet package to your projects 3. Text files will be added to your project, open them and copy over the coresponding file in each project as appropriate. - `MainActivity.cs.txt` for Android, - `AppDelegate.cs.txt` for iOS, or - `MainPage.xaml.txt` and `MainPage.xaml.cs.txt` for WinPhone. + - Windows 10 Universal doesn't currently add files, see below for what to change. 4. Once you are done with them, you can delete the text files that were added to your project. -5. On Windows Phone, you will also need to add `Xamarin.Forms.Forms.Init(e);` to `App.OnLaunched()`. +5. On Windows Phone and Windows Universal, you will also need to add `Xamarin.Forms.Forms.Init(e);` to `App.OnLaunched()`. 6. Write your unit tests in this project, or in a shared project 7. Build and run the tests on your device or emulator @@ -137,6 +139,8 @@ public sealed partial class MainPage : WindowsPhonePage ```C# protected override void OnLaunched(LaunchActivatedEventArgs e) { + // + Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, @@ -163,5 +167,89 @@ protected override void OnLaunched(LaunchActivatedEventArgs e) // Place the frame in the current Window Window.Current.Content = rootFrame; } + + // +} +``` + + + +### Windows 10 Universal ### + +**MainPage.xaml** + +```XML + + + + + + +``` + +**MainPage.xaml.cs** + +```C# +public sealed partial class MainPage : WindowsPage +{ + public MainPage() + { + InitializeComponent(); + + // Windows Universal will not load all tests within the current project, + // you must do it explicitly below + var nunit = new NUnit.Runner.App(); + + // If you want to add tests in another assembly, add a reference and + // duplicate the following line with a type from the referenced assembly + nunit.AddTestAssembly(typeof(MainPage).GetTypeInfo().Assembly); + + // Do you want to automatically run tests when the app starts? + nunit.AutoRun = true; + + LoadApplication(nunit); + } +} +``` + +**App.xaml.cs** + +```C# +protected override void OnLaunched(LaunchActivatedEventArgs e) +{ + // + + Frame rootFrame = Window.Current.Content as Frame; + + // Do not repeat app initialization when the Window already has content, + // just ensure that the window is active + if (rootFrame == null) + { + // Create a Frame to act as the navigation context and navigate to the first page + rootFrame = new Frame(); + + rootFrame.NavigationFailed += OnNavigationFailed; + + // ==> ADD THIS LINE <== + Xamarin.Forms.Forms.Init(e); + + if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) + { + // TODO: Load state from previously suspended application + } + + // Place the frame in the current Window + Window.Current.Content = rootFrame; + } + + // } ``` \ No newline at end of file diff --git a/nuget/nunit.runners.xamarin.nuspec b/nuget/nunit.runners.xamarin.nuspec index df82a33..c48593e 100644 --- a/nuget/nunit.runners.xamarin.nuspec +++ b/nuget/nunit.runners.xamarin.nuspec @@ -11,7 +11,8 @@ Supported Xamarin platforms: - Android - iOS - - Windows Phone 8.1 + - Windows Phone 8.1 + - Windows 10 Universal Apps NUnit 3.0 runner components for Xamarin nunit xamarin android ios monoandroid monotouch winphone tdd unit test testing en-US @@ -41,5 +42,8 @@ Supported Xamarin platforms: + + +