diff --git a/ReactWindows/.gitignore b/ReactWindows/.gitignore
new file mode 100644
index 00000000000..996016dc621
--- /dev/null
+++ b/ReactWindows/.gitignore
@@ -0,0 +1,76 @@
+*AppPackages*
+
+#OS junk files
+[Tt]humbs.db
+*.DS_Store
+
+#Visual Studio files
+*.[Oo]bj
+*.user
+*.aps
+*.pch
+*.vspscc
+*.vssscc
+*_i.c
+*_p.c
+*.ncb
+*.suo
+*.tlb
+*.tlh
+*.bak
+*.[Cc]ache
+*.ilk
+*.log
+*.lib
+*.sbr
+*.sdf
+*.opensdf
+*.opendb
+*.unsuccessfulbuild
+ipch/
+[Oo]bj/
+[Bb]in
+[Dd]ebug*/
+[Rr]elease*/
+Ankh.NoLoad
+
+#MonoDevelop
+*.pidb
+*.userprefs
+
+#Tooling
+_ReSharper*/
+*.resharper
+[Tt]est[Rr]esult*
+*.sass-cache
+
+#Project files
+[Bb]uild/
+
+#Subversion files
+.svn
+
+# Office Temp Files
+~$*
+
+# vim Temp Files
+*~
+
+#NuGet
+packages/
+*.nupkg
+
+#ncrunch
+*ncrunch*
+*crunch*.local.xml
+
+# visual studio database projects
+*.dbmdl
+
+#Test files
+*.testsettings
+
+#Other files
+*.DotSettings
+.vs/
+*project.lock.json
\ No newline at end of file
diff --git a/ReactWindows/Playground/App.xaml b/ReactWindows/Playground/App.xaml
new file mode 100644
index 00000000000..33929dda240
--- /dev/null
+++ b/ReactWindows/Playground/App.xaml
@@ -0,0 +1,8 @@
+
+
+
diff --git a/ReactWindows/Playground/App.xaml.cs b/ReactWindows/Playground/App.xaml.cs
new file mode 100644
index 00000000000..5cf14d70460
--- /dev/null
+++ b/ReactWindows/Playground/App.xaml.cs
@@ -0,0 +1,108 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices.WindowsRuntime;
+using Windows.ApplicationModel;
+using Windows.ApplicationModel.Activation;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Controls.Primitives;
+using Windows.UI.Xaml.Data;
+using Windows.UI.Xaml.Input;
+using Windows.UI.Xaml.Media;
+using Windows.UI.Xaml.Navigation;
+
+namespace Playground
+{
+ ///
+ /// Provides application-specific behavior to supplement the default Application class.
+ ///
+ sealed partial class App : Application
+ {
+ ///
+ /// Initializes the singleton application object. This is the first line of authored code
+ /// executed, and as such is the logical equivalent of main() or WinMain().
+ ///
+ public App()
+ {
+ Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync(
+ Microsoft.ApplicationInsights.WindowsCollectors.Metadata |
+ Microsoft.ApplicationInsights.WindowsCollectors.Session);
+ this.InitializeComponent();
+ this.Suspending += OnSuspending;
+ }
+
+ ///
+ /// Invoked when the application is launched normally by the end user. Other entry points
+ /// will be used such as when the application is launched to open a specific file.
+ ///
+ /// Details about the launch request and process.
+ protected override void OnLaunched(LaunchActivatedEventArgs e)
+ {
+
+#if DEBUG
+ if (System.Diagnostics.Debugger.IsAttached)
+ {
+ this.DebugSettings.EnableFrameRateCounter = true;
+ }
+#endif
+
+ 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;
+
+ if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
+ {
+ //TODO: Load state from previously suspended application
+ }
+
+ // Place the frame in the current Window
+ Window.Current.Content = rootFrame;
+ }
+
+ if (rootFrame.Content == null)
+ {
+ // When the navigation stack isn't restored navigate to the first page,
+ // configuring the new page by passing required information as a navigation
+ // parameter
+ rootFrame.Navigate(typeof(MainPage), e.Arguments);
+ }
+ // Ensure the current window is active
+ Window.Current.Activate();
+ }
+
+ ///
+ /// Invoked when Navigation to a certain page fails
+ ///
+ /// The Frame which failed navigation
+ /// Details about the navigation failure
+ void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
+ {
+ throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
+ }
+
+ ///
+ /// Invoked when application execution is being suspended. Application state is saved
+ /// without knowing whether the application will be terminated or resumed with the contents
+ /// of memory still intact.
+ ///
+ /// The source of the suspend request.
+ /// Details about the suspend request.
+ private void OnSuspending(object sender, SuspendingEventArgs e)
+ {
+ var deferral = e.SuspendingOperation.GetDeferral();
+ //TODO: Save application state and stop any background activity
+ deferral.Complete();
+ }
+ }
+}
diff --git a/ReactWindows/Playground/ApplicationInsights.config b/ReactWindows/Playground/ApplicationInsights.config
new file mode 100644
index 00000000000..cb2a232da35
--- /dev/null
+++ b/ReactWindows/Playground/ApplicationInsights.config
@@ -0,0 +1,3 @@
+
+
+
diff --git a/ReactWindows/Playground/Assets/LockScreenLogo.scale-200.png b/ReactWindows/Playground/Assets/LockScreenLogo.scale-200.png
new file mode 100644
index 00000000000..735f57adb5d
Binary files /dev/null and b/ReactWindows/Playground/Assets/LockScreenLogo.scale-200.png differ
diff --git a/ReactWindows/Playground/Assets/SplashScreen.scale-200.png b/ReactWindows/Playground/Assets/SplashScreen.scale-200.png
new file mode 100644
index 00000000000..023e7f1feda
Binary files /dev/null and b/ReactWindows/Playground/Assets/SplashScreen.scale-200.png differ
diff --git a/ReactWindows/Playground/Assets/Square150x150Logo.scale-200.png b/ReactWindows/Playground/Assets/Square150x150Logo.scale-200.png
new file mode 100644
index 00000000000..af49fec1a54
Binary files /dev/null and b/ReactWindows/Playground/Assets/Square150x150Logo.scale-200.png differ
diff --git a/ReactWindows/Playground/Assets/Square44x44Logo.scale-200.png b/ReactWindows/Playground/Assets/Square44x44Logo.scale-200.png
new file mode 100644
index 00000000000..ce342a2ec8a
Binary files /dev/null and b/ReactWindows/Playground/Assets/Square44x44Logo.scale-200.png differ
diff --git a/ReactWindows/Playground/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/ReactWindows/Playground/Assets/Square44x44Logo.targetsize-24_altform-unplated.png
new file mode 100644
index 00000000000..f6c02ce97e0
Binary files /dev/null and b/ReactWindows/Playground/Assets/Square44x44Logo.targetsize-24_altform-unplated.png differ
diff --git a/ReactWindows/Playground/Assets/StoreLogo.png b/ReactWindows/Playground/Assets/StoreLogo.png
new file mode 100644
index 00000000000..7385b56c0e4
Binary files /dev/null and b/ReactWindows/Playground/Assets/StoreLogo.png differ
diff --git a/ReactWindows/Playground/Assets/Wide310x150Logo.scale-200.png b/ReactWindows/Playground/Assets/Wide310x150Logo.scale-200.png
new file mode 100644
index 00000000000..288995b397f
Binary files /dev/null and b/ReactWindows/Playground/Assets/Wide310x150Logo.scale-200.png differ
diff --git a/ReactWindows/Playground/MainPage.xaml b/ReactWindows/Playground/MainPage.xaml
new file mode 100644
index 00000000000..f09931990a1
--- /dev/null
+++ b/ReactWindows/Playground/MainPage.xaml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
diff --git a/ReactWindows/Playground/MainPage.xaml.cs b/ReactWindows/Playground/MainPage.xaml.cs
new file mode 100644
index 00000000000..1189daa7f1b
--- /dev/null
+++ b/ReactWindows/Playground/MainPage.xaml.cs
@@ -0,0 +1,46 @@
+using ReactNative.Hosting;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices.WindowsRuntime;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Controls.Primitives;
+using Windows.UI.Xaml.Data;
+using Windows.UI.Xaml.Input;
+using Windows.UI.Xaml.Media;
+using Windows.UI.Xaml.Navigation;
+
+// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
+
+namespace Playground
+{
+ ///
+ /// An empty page that can be used on its own or navigated to within a Frame.
+ ///
+ public sealed partial class MainPage : Page
+ {
+ public MainPage()
+ {
+ this.InitializeComponent();
+ }
+
+ protected override void OnNavigatedTo(NavigationEventArgs e)
+ {
+ base.OnNavigatedTo(e);
+
+ try
+ {
+ var runtime = new JavaScriptRuntime();
+ var context = runtime.CreateContext();
+ }
+ catch (Exception ex)
+ {
+
+ }
+ }
+ }
+}
diff --git a/ReactWindows/Playground/Package.appxmanifest b/ReactWindows/Playground/Package.appxmanifest
new file mode 100644
index 00000000000..12652801043
--- /dev/null
+++ b/ReactWindows/Playground/Package.appxmanifest
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+ Playground
+ ericroz
+ Assets\StoreLogo.png
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ReactWindows/Playground/Playground.csproj b/ReactWindows/Playground/Playground.csproj
new file mode 100644
index 00000000000..981e75778dd
--- /dev/null
+++ b/ReactWindows/Playground/Playground.csproj
@@ -0,0 +1,149 @@
+
+
+
+
+ Debug
+ x86
+ {D52267B5-396F-424A-BB26-C9E750032846}
+ AppContainerExe
+ Properties
+ Playground
+ Playground
+ en-US
+ UAP
+ 10.0.10586.0
+ 10.0.10240.0
+ 14
+ 512
+ {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ Playground_TemporaryKey.pfx
+
+
+ true
+ bin\x86\Debug\
+ DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ ;2008
+ full
+ x86
+ false
+ prompt
+ true
+
+
+ bin\x86\Release\
+ TRACE;NETFX_CORE;WINDOWS_UWP
+ true
+ ;2008
+ pdbonly
+ x86
+ false
+ prompt
+ true
+ true
+
+
+ true
+ bin\ARM\Debug\
+ DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ ;2008
+ full
+ ARM
+ false
+ prompt
+ true
+
+
+ bin\ARM\Release\
+ TRACE;NETFX_CORE;WINDOWS_UWP
+ true
+ ;2008
+ pdbonly
+ ARM
+ false
+ prompt
+ true
+ true
+
+
+ true
+ bin\x64\Debug\
+ DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ ;2008
+ full
+ x64
+ false
+ prompt
+ true
+
+
+ bin\x64\Release\
+ TRACE;NETFX_CORE;WINDOWS_UWP
+ true
+ ;2008
+ pdbonly
+ x64
+ false
+ prompt
+ true
+ true
+
+
+
+
+ PreserveNewest
+
+
+
+
+
+ App.xaml
+
+
+ MainPage.xaml
+
+
+
+
+
+ Designer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+
+
+ {c7673ad5-e3aa-468c-a5fd-fa38154e205c}
+ ReactNative
+
+
+
+ 14.0
+
+
+
+
\ No newline at end of file
diff --git a/ReactWindows/Playground/Playground_TemporaryKey.pfx b/ReactWindows/Playground/Playground_TemporaryKey.pfx
new file mode 100644
index 00000000000..65693d19327
Binary files /dev/null and b/ReactWindows/Playground/Playground_TemporaryKey.pfx differ
diff --git a/ReactWindows/Playground/Properties/AssemblyInfo.cs b/ReactWindows/Playground/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000000..0793c0ed293
--- /dev/null
+++ b/ReactWindows/Playground/Properties/AssemblyInfo.cs
@@ -0,0 +1,29 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Playground")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Playground")]
+[assembly: AssemblyCopyright("Copyright © 2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: ComVisible(false)]
\ No newline at end of file
diff --git a/ReactWindows/Playground/Properties/Default.rd.xml b/ReactWindows/Playground/Properties/Default.rd.xml
new file mode 100644
index 00000000000..80a960ce32f
--- /dev/null
+++ b/ReactWindows/Playground/Properties/Default.rd.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ReactWindows/Playground/project.json b/ReactWindows/Playground/project.json
new file mode 100644
index 00000000000..e3b2dba25fa
--- /dev/null
+++ b/ReactWindows/Playground/project.json
@@ -0,0 +1,19 @@
+{
+ "dependencies": {
+ "Microsoft.ApplicationInsights": "1.0.0",
+ "Microsoft.ApplicationInsights.PersistenceChannel": "1.0.0",
+ "Microsoft.ApplicationInsights.WindowsApps": "1.0.0",
+ "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0"
+ },
+ "frameworks": {
+ "uap10.0": {}
+ },
+ "runtimes": {
+ "win10-arm": {},
+ "win10-arm-aot": {},
+ "win10-x86": {},
+ "win10-x86-aot": {},
+ "win10-x64": {},
+ "win10-x64-aot": {}
+ }
+}
\ No newline at end of file
diff --git a/ReactWindows/ReactNative.Tests/Assets/LockScreenLogo.scale-200.png b/ReactWindows/ReactNative.Tests/Assets/LockScreenLogo.scale-200.png
new file mode 100644
index 00000000000..735f57adb5d
Binary files /dev/null and b/ReactWindows/ReactNative.Tests/Assets/LockScreenLogo.scale-200.png differ
diff --git a/ReactWindows/ReactNative.Tests/Assets/SplashScreen.scale-200.png b/ReactWindows/ReactNative.Tests/Assets/SplashScreen.scale-200.png
new file mode 100644
index 00000000000..023e7f1feda
Binary files /dev/null and b/ReactWindows/ReactNative.Tests/Assets/SplashScreen.scale-200.png differ
diff --git a/ReactWindows/ReactNative.Tests/Assets/Square150x150Logo.scale-200.png b/ReactWindows/ReactNative.Tests/Assets/Square150x150Logo.scale-200.png
new file mode 100644
index 00000000000..af49fec1a54
Binary files /dev/null and b/ReactWindows/ReactNative.Tests/Assets/Square150x150Logo.scale-200.png differ
diff --git a/ReactWindows/ReactNative.Tests/Assets/Square44x44Logo.scale-200.png b/ReactWindows/ReactNative.Tests/Assets/Square44x44Logo.scale-200.png
new file mode 100644
index 00000000000..ce342a2ec8a
Binary files /dev/null and b/ReactWindows/ReactNative.Tests/Assets/Square44x44Logo.scale-200.png differ
diff --git a/ReactWindows/ReactNative.Tests/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/ReactWindows/ReactNative.Tests/Assets/Square44x44Logo.targetsize-24_altform-unplated.png
new file mode 100644
index 00000000000..f6c02ce97e0
Binary files /dev/null and b/ReactWindows/ReactNative.Tests/Assets/Square44x44Logo.targetsize-24_altform-unplated.png differ
diff --git a/ReactWindows/ReactNative.Tests/Assets/StoreLogo.png b/ReactWindows/ReactNative.Tests/Assets/StoreLogo.png
new file mode 100644
index 00000000000..7385b56c0e4
Binary files /dev/null and b/ReactWindows/ReactNative.Tests/Assets/StoreLogo.png differ
diff --git a/ReactWindows/ReactNative.Tests/Assets/Wide310x150Logo.scale-200.png b/ReactWindows/ReactNative.Tests/Assets/Wide310x150Logo.scale-200.png
new file mode 100644
index 00000000000..288995b397f
Binary files /dev/null and b/ReactWindows/ReactNative.Tests/Assets/Wide310x150Logo.scale-200.png differ
diff --git a/ReactWindows/ReactNative.Tests/Bridge/JavaScriptModuleRegistryTests.cs b/ReactWindows/ReactNative.Tests/Bridge/JavaScriptModuleRegistryTests.cs
new file mode 100644
index 00000000000..8ab7f6545d9
--- /dev/null
+++ b/ReactWindows/ReactNative.Tests/Bridge/JavaScriptModuleRegistryTests.cs
@@ -0,0 +1,97 @@
+using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using ReactNative.Bridge;
+using ReactNative.Modules.Core;
+using ReactNative.UIManager;
+using System;
+using System.Collections.Generic;
+using System.Threading;
+
+namespace ReactNative.Tests.Bridge
+{
+ [TestClass]
+ public class JavaScriptModuleRegistryTests
+ {
+ [TestMethod]
+ public void JavaScriptModuleRegistry_ArgumentChecks()
+ {
+ var catalystInstance = new MockCatalystInstance();
+ var config = new JavaScriptModulesConfig.Builder().Build();
+
+ AssertEx.Throws(
+ () => new JavaScriptModuleRegistry(null, config),
+ ex => Assert.AreEqual("catalystInstance", ex.ParamName));
+
+ AssertEx.Throws(
+ () => new JavaScriptModuleRegistry(catalystInstance, null),
+ ex => Assert.AreEqual("config", ex.ParamName));
+ }
+
+ [TestMethod]
+ public void JavaScriptModuleRegistry_Invoke()
+ {
+ var config = new JavaScriptModulesConfig.Builder()
+ .Add()
+ .Add()
+ .Add()
+ .Build();
+
+ var are = new AutoResetEvent(false);
+ var moduleIds = new List();
+ var methodIds = new List();
+ var argsList = new List();
+ var catalystInstance = new MockCatalystInstance((moduleId, methodId, args, tracingName) =>
+ {
+ moduleIds.Add(moduleId);
+ methodIds.Add(methodId);
+ argsList.Add(args);
+ are.Set();
+ });
+
+ var registry = new JavaScriptModuleRegistry(catalystInstance, config);
+ var module = registry.GetJavaScriptModule();
+
+ module.Foo(42);
+
+ are.WaitOne();
+
+ Assert.AreEqual(1, moduleIds.Count);
+ Assert.AreEqual(1, methodIds.Count);
+ Assert.AreEqual(1, moduleIds.Count);
+
+ Assert.AreEqual(2, moduleIds[0]);
+ Assert.AreEqual(2, methodIds[0]);
+ Assert.AreEqual(
+ JArray.FromObject(new[] { 42 }).ToString(Formatting.None),
+ argsList[0].ToString(Formatting.None));
+ }
+
+ [TestMethod]
+ public void JavaScriptModuleRegistry_InvalidModule_Throws()
+ {
+ var config = new JavaScriptModulesConfig.Builder().Build();
+ var catalystInstance = new MockCatalystInstance();
+ var registry = new JavaScriptModuleRegistry(catalystInstance, config);
+ AssertEx.Throws(() => registry.GetJavaScriptModule());
+ }
+
+ class TestJavaScriptModule : JavaScriptModuleBase
+ {
+ public void Bar()
+ {
+ Invoke(nameof(Bar));
+ }
+
+ public void Baz()
+ {
+ Invoke(nameof(Baz));
+ }
+
+ public void Foo(int x)
+ {
+ Invoke(nameof(Foo), x);
+ }
+ }
+ }
+}
diff --git a/ReactWindows/ReactNative.Tests/Bridge/JavaScriptModulesConfigTests.cs b/ReactWindows/ReactNative.Tests/Bridge/JavaScriptModulesConfigTests.cs
new file mode 100644
index 00000000000..f3ba394a53c
--- /dev/null
+++ b/ReactWindows/ReactNative.Tests/Bridge/JavaScriptModulesConfigTests.cs
@@ -0,0 +1,102 @@
+using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using ReactNative.Bridge;
+using System;
+using System.Collections.Generic;
+using System.IO;
+
+namespace ReactNative.Tests.Bridge
+{
+ [TestClass]
+ public class JavaScriptModulesConfigTests
+ {
+ [TestMethod]
+ public void JavaScriptModulesConfig_MethodOverrides_ThrowsNotSupported()
+ {
+ var builder = new JavaScriptModulesConfig.Builder();
+ AssertEx.Throws(() => builder.Add());
+ }
+
+ [TestMethod]
+ public void JavaScriptModulesConfig_WriteModuleDefinitions()
+ {
+ var builder = new JavaScriptModulesConfig.Builder();
+ builder.Add();
+ var config = builder.Build();
+
+ using (var stringWriter = new StringWriter())
+ {
+ using (var writer = new JsonTextWriter(stringWriter))
+ {
+ config.WriteModuleDescriptions(writer);
+ }
+
+ var actual = stringWriter.ToString();
+ var expected = JObject.FromObject(
+ new Map
+ {
+ {
+ "TestJavaScriptModule",
+ new Map
+ {
+ { "moduleID", 0 },
+ {
+ "methods",
+ new Map
+ {
+ {
+ "Bar",
+ new Map
+ {
+ { "methodID", 0 },
+ }
+ },
+ {
+ "Foo",
+ new Map
+ {
+ { "methodID", 1 },
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ ).ToString(Formatting.None);
+
+ Assert.AreEqual(expected, actual);
+ }
+ }
+ }
+
+ public class Map : Dictionary { }
+
+ public class OverridesJavaScriptModule : JavaScriptModuleBase
+ {
+ public void Foo()
+ {
+ Invoke(nameof(Foo));
+ }
+
+
+ public void Foo(int x)
+ {
+ Invoke(nameof(Foo), x);
+ }
+ }
+
+ public class TestJavaScriptModule : JavaScriptModuleBase
+ {
+ public void Bar()
+ {
+ Invoke(nameof(Bar));
+ }
+
+ public void Foo()
+ {
+ Invoke(nameof(Foo));
+ }
+ }
+}
diff --git a/ReactWindows/ReactNative.Tests/Bridge/NativeModuleBaseTests.cs b/ReactWindows/ReactNative.Tests/Bridge/NativeModuleBaseTests.cs
new file mode 100644
index 00000000000..edd4ab8987a
--- /dev/null
+++ b/ReactWindows/ReactNative.Tests/Bridge/NativeModuleBaseTests.cs
@@ -0,0 +1,230 @@
+using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
+using Newtonsoft.Json.Linq;
+using ReactNative.Bridge;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace ReactNative.Tests.Bridge
+{
+ [TestClass]
+ public class NativeModuleBaseTests
+ {
+ [TestMethod]
+ public void NativeModuleBase_MethodOverload_ThrowsNotSupported()
+ {
+ AssertEx.Throws(() => new MethodOverloadNativeModule());
+ }
+
+ [TestMethod]
+ public void NativeModuleBase_Invocation_ArgumentNull()
+ {
+ var testModule = new TestNativeModule();
+
+ testModule.Initialize();
+
+ var catalystInstance = new MockCatalystInstance();
+ AssertEx.Throws(
+ () => testModule.Methods[nameof(TestNativeModule.Foo)].Invoke(null, new JArray()),
+ ex => Assert.AreEqual("catalystInstance", ex.ParamName));
+ AssertEx.Throws(
+ () => testModule.Methods[nameof(TestNativeModule.Foo)].Invoke(catalystInstance, null),
+ ex => Assert.AreEqual("jsArguments", ex.ParamName));
+ }
+
+ [TestMethod]
+ public void NativeModuleBase_Invocation_ArgumentInvalidCount()
+ {
+ var testModule = new TestNativeModule();
+
+ testModule.Initialize();
+
+ var catalystInstance = new MockCatalystInstance();
+ AssertEx.Throws(
+ () => testModule.Methods[nameof(TestNativeModule.Bar)].Invoke(catalystInstance, new JArray()),
+ ex => Assert.AreEqual("jsArguments", ex.ParamName));
+ }
+
+ [TestMethod]
+ public void NativeModuleBase_Invocation_ArgumentConversionException()
+ {
+ var testModule = new TestNativeModule();
+
+ testModule.Initialize();
+
+ var catalystInstance = new MockCatalystInstance();
+ AssertEx.Throws(
+ () => testModule.Methods[nameof(TestNativeModule.Bar)].Invoke(catalystInstance, JArray.FromObject(new[] { default(object) })),
+ ex => Assert.AreEqual("jsArguments", ex.ParamName));
+ }
+
+ [TestMethod]
+ public void NativeModuleBase_Invocation()
+ {
+ var fooCount = 0;
+ var barSum = 0;
+ var testModule = new TestNativeModule(() => fooCount++, x => barSum += x);
+
+ testModule.Initialize();
+
+ Assert.AreEqual(2, testModule.Methods.Count);
+
+ var catalystInstance = new MockCatalystInstance();
+ testModule.Methods[nameof(TestNativeModule.Foo)].Invoke(catalystInstance, new JArray());
+ testModule.Methods[nameof(TestNativeModule.Foo)].Invoke(catalystInstance, new JArray());
+ Assert.AreEqual(2, fooCount);
+
+ testModule.Methods[nameof(TestNativeModule.Bar)].Invoke(catalystInstance, JArray.FromObject(new[] { 42 }));
+ testModule.Methods[nameof(TestNativeModule.Bar)].Invoke(catalystInstance, JArray.FromObject(new[] { 17 }));
+ Assert.AreEqual(59, barSum);
+ }
+
+ [TestMethod]
+ public void NativeModuleBase_Invocation_Callbacks()
+ {
+ var callbackArgs = new object[] { 1, 2, 3 };
+ var module = new CallbackNativeModule(callbackArgs);
+ module.Initialize();
+
+ var id = default(int);
+ var args = default(List);
+
+ var catalystInstance = new MockCatalystInstance((i, a) =>
+ {
+ id = i;
+ args = a.ToObject>();
+ });
+
+ module.Methods[nameof(CallbackNativeModule.Foo)].Invoke(catalystInstance, JArray.FromObject(new[] { 42 }));
+ Assert.AreEqual(42, id);
+ Assert.IsTrue(args.Cast