public void NativeModuleBase_Invocation_ArgumentConversionException()
        {
            var testModule = new TestNativeModule();

            testModule.Initialize();

            var reactInstance = new MockReactInstance();
            AssertEx.Throws<NativeArgumentsParseException>(
                () => testModule.Methods[nameof(TestNativeModule.Bar)].Invoke(reactInstance, JArray.FromObject(new[] { default(object) })),
                ex => Assert.AreEqual("arguments", ex.ParamName));
        }
        public void NativeModuleBase_Invocation_ArgumentInvalidCount()
        {
            var testModule = new TestNativeModule();

            testModule.Initialize();

            var reactInstance = new MockReactInstance();
            AssertEx.Throws<NativeArgumentsParseException>(
                () => testModule.Methods[nameof(TestNativeModule.Bar)].Invoke(reactInstance, new JArray()),
                ex => Assert.AreEqual("jsArguments", ex.ParamName));
        }
Example #3
0
        public void NativeModuleBase_Invocation_ArgumentConversionException()
        {
            var testModule = new TestNativeModule();

            testModule.Initialize();

            var reactInstance = new MockReactInstance();

            AssertEx.Throws <NativeArgumentsParseException>(
                () => testModule.Methods[nameof(TestNativeModule.Bar)].Invoke(reactInstance, JArray.FromObject(new[] { default(object) })),
                ex => Assert.AreEqual("jsArguments", ex.ParamName));
        }
Example #4
0
        public void NativeModuleBase_Invocation_ArgumentInvalidCount()
        {
            var testModule = new TestNativeModule();

            testModule.Initialize();

            var reactInstance = new MockReactInstance();

            AssertEx.Throws <NativeArgumentsParseException>(
                () => testModule.Methods[nameof(TestNativeModule.Bar)].Invoke(reactInstance, new JArray()),
                ex => Assert.AreEqual("jsArguments", ex.ParamName));
        }
Example #5
0
        public void NativeModuleBase_Invocation_ArgumentInvalidCount()
        {
            var testModule = new TestNativeModule();

            testModule.Initialize();

            var nopCallback = new InvokeCallback((_, __) => { });

            AssertEx.Throws <NativeArgumentsParseException>(
                () => testModule.Methods[nameof(TestNativeModule.Bar)].Invoke(nopCallback, new JArray()),
                ex => Assert.AreEqual("jsArguments", ex.ParamName));
        }
        public void NativeModuleBase_Invocation_ArgumentNull()
        {
            var testModule = new TestNativeModule();

            testModule.Initialize();

            var reactInstance = new MockReactInstance();
            AssertEx.Throws<ArgumentNullException>(
                () => testModule.Methods[nameof(TestNativeModule.Foo)].Invoke(null, new JArray()),
                ex => Assert.AreEqual("reactInstance", ex.ParamName));
            AssertEx.Throws<ArgumentNullException>(
                () => testModule.Methods[nameof(TestNativeModule.Foo)].Invoke(reactInstance, null),
                ex => Assert.AreEqual("jsArguments", ex.ParamName));
        }
Example #7
0
        public void NativeModuleBase_Invocation_ArgumentNull()
        {
            var testModule = new TestNativeModule();

            testModule.Initialize();

            var reactInstance = new MockReactInstance();

            AssertEx.Throws <ArgumentNullException>(
                () => testModule.Methods[nameof(TestNativeModule.Foo)].Invoke(null, new JArray()),
                ex => Assert.AreEqual("reactInstance", ex.ParamName));
            AssertEx.Throws <ArgumentNullException>(
                () => testModule.Methods[nameof(TestNativeModule.Foo)].Invoke(reactInstance, null),
                ex => Assert.AreEqual("jsArguments", ex.ParamName));
        }
Example #8
0
        public void NativeModuleBase_Invocation_ArgumentNull()
        {
            var testModule = new TestNativeModule();

            testModule.Initialize();

            var nopCallback = new InvokeCallback((_, __) => { });

            AssertEx.Throws <ArgumentNullException>(
                () => testModule.Methods[nameof(TestNativeModule.Foo)].Invoke(null, new JArray()),
                ex => Assert.AreEqual("invokeCallback", ex.ParamName));
            AssertEx.Throws <ArgumentNullException>(
                () => testModule.Methods[nameof(TestNativeModule.Foo)].Invoke(nopCallback, null),
                ex => Assert.AreEqual("jsArguments", ex.ParamName));
        }
Example #9
0
        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 reactInstance = new MockReactInstance();

            testModule.Methods[nameof(TestNativeModule.Foo)].Invoke(reactInstance, new JArray());
            testModule.Methods[nameof(TestNativeModule.Foo)].Invoke(reactInstance, new JArray());
            Assert.AreEqual(2, fooCount);

            testModule.Methods[nameof(TestNativeModule.Bar)].Invoke(reactInstance, JArray.FromObject(new[] { 42 }));
            testModule.Methods[nameof(TestNativeModule.Bar)].Invoke(reactInstance, JArray.FromObject(new[] { 17 }));
            Assert.AreEqual(59, barSum);
        }
Example #10
0
        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 nopCallback = new InvokeCallback((_, __) => { });

            testModule.Methods[nameof(TestNativeModule.Foo)].Invoke(nopCallback, new JArray());
            testModule.Methods[nameof(TestNativeModule.Foo)].Invoke(nopCallback, new JArray());
            Assert.AreEqual(2, fooCount);

            testModule.Methods[nameof(TestNativeModule.Bar)].Invoke(nopCallback, JArray.FromObject(new[] { 42 }));
            testModule.Methods[nameof(TestNativeModule.Bar)].Invoke(nopCallback, JArray.FromObject(new[] { 17 }));
            Assert.AreEqual(59, barSum);
        }
        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 reactInstance = new MockReactInstance();
            testModule.Methods[nameof(TestNativeModule.Foo)].Invoke(reactInstance, new JArray());
            testModule.Methods[nameof(TestNativeModule.Foo)].Invoke(reactInstance, new JArray());
            Assert.AreEqual(2, fooCount);

            testModule.Methods[nameof(TestNativeModule.Bar)].Invoke(reactInstance, JArray.FromObject(new[] { 42 }));
            testModule.Methods[nameof(TestNativeModule.Bar)].Invoke(reactInstance, JArray.FromObject(new[] { 17 }));
            Assert.AreEqual(59, barSum);
        }