Esempio n. 1
0
        public void NetInfoModule_JsonResponse()
        {
            var networkInfo = new MockNetworkInformation();
            var context     = CreateReactContext();
            var netInfo     = new NetInfoModule(networkInfo, context);

            var state   = default(JObject);
            var promise = new MockPromise(value => state = (JObject)value);

            netInfo.getCurrentConnectivity(promise);
            Assert.AreEqual(CreateNetworkInfo(NetworkConnectivityLevel.None.ToString()).ToString(Formatting.None), state.ToString(Formatting.None));

            networkInfo.CurrentConnectionProfile = new MockConnectionProfile(NetworkConnectivityLevel.None);
            netInfo.getCurrentConnectivity(promise);
            Assert.AreEqual(CreateNetworkInfo(NetworkConnectivityLevel.None.ToString()).ToString(Formatting.None), state.ToString(Formatting.None));

            networkInfo.CurrentConnectionProfile = new MockConnectionProfile(NetworkConnectivityLevel.LocalAccess);
            netInfo.getCurrentConnectivity(promise);
            Assert.AreEqual(CreateNetworkInfo(NetworkConnectivityLevel.LocalAccess.ToString()).ToString(Formatting.None), state.ToString(Formatting.None));

            networkInfo.CurrentConnectionProfile = new MockConnectionProfile(NetworkConnectivityLevel.ConstrainedInternetAccess);
            netInfo.getCurrentConnectivity(promise);
            Assert.AreEqual(CreateNetworkInfo(NetworkConnectivityLevel.ConstrainedInternetAccess.ToString()).ToString(Formatting.None), state.ToString(Formatting.None));

            networkInfo.CurrentConnectionProfile = new MockConnectionProfile(NetworkConnectivityLevel.InternetAccess);
            netInfo.getCurrentConnectivity(promise);
            Assert.AreEqual(CreateNetworkInfo(NetworkConnectivityLevel.InternetAccess.ToString()).ToString(Formatting.None), state.ToString(Formatting.None));
        }
        public void ClipboardModule_SetString_Null_Method()
        {
            var module     = new ClipboardModule();
            var result     = "";
            var waitHandle = new AutoResetEvent(false);

            var promise = new MockPromise(resolve => { result = resolve.ToString(); waitHandle.Set(); },
                                          reject => { result = reject; waitHandle.Set(); });

            module.setString(null);
            module.getString(promise);

            waitHandle.WaitOne();
            Assert.AreEqual("", result);
        }
Esempio n. 3
0
        public void ImageLoaderModule_getSize_Local()
        {
            var module = new ImageLoaderModule();

            var result     = "";
            var str        = "{\r\n  \"width\": 50,\r\n  \"height\": 50\r\n}";
            var waitHandle = new AutoResetEvent(false);

            var promise = new MockPromise(resolve => { result = resolve.ToString(); waitHandle.Set(); },
                                          (code, message, e) => { result = message; waitHandle.Set(); });

            module.getSize(LocalUri, promise);

            waitHandle.WaitOne();
            Assert.AreEqual(str, result);
        }
Esempio n. 4
0
        public void ClipboardModule_SetString_Null_Method()
        {
            var clipboard = new MockClipboardInstance();
            var module    = new ClipboardModule(clipboard);

            var result     = "";
            var waitHandle = new AutoResetEvent(false);

            var promise = new MockPromise(resolve => { result = resolve.ToString(); waitHandle.Set(); },
                                          (code, message, stack, userInfo) => { result = message; waitHandle.Set(); });

            module.setString(null);
            module.getString(promise);

            waitHandle.WaitOne();
            Assert.AreEqual("", result);
        }
        public void ClipboardModule_GetString_Method()
        {
            var module = new ClipboardModule();

            var result     = "";
            var str        = "test string";
            var waitHandle = new AutoResetEvent(false);

            var promise = new MockPromise(resolve => { result = resolve.ToString(); waitHandle.Set(); },
                                          (code, message, e) => { result = message; waitHandle.Set(); });

            module.setString(str);
            module.getString(promise);

            waitHandle.WaitOne();
            Assert.AreEqual(str, result);
        }
        public void NetInfoModule_JsonResponse()
        {
            var networkInterface = new MockNetworkListManager("None");
            var networkInfo      = new MockNetworkInformation(networkInterface);
            var context          = CreateReactContext();
            var netInfo          = new NetInfoModule(networkInfo, context);

            var state   = default(JObject);
            var promise = new MockPromise(value => state = (JObject)value);

            netInfo.getCurrentConnectivity(promise);
            Assert.AreEqual(CreateNetworkInfo("None"), state);

            networkInfo.networkListManager = new MockNetworkListManager("InternetAccess");
            netInfo.getCurrentConnectivity(promise);
            Assert.AreEqual(CreateNetworkInfo("InternetAccess"), state);
        }
Esempio n. 7
0
        public void ImageLoaderModule_getSize_Network()
        {
            var module = new ImageLoaderModule();

            var result     = "";
            var str        = "{\r\n  \"width\": 1200,\r\n  \"height\": 630\r\n}";
            var waitHandle = new AutoResetEvent(false);

            var promise = new MockPromise(resolve => { result = resolve.ToString(); waitHandle.Set(); },
                                          (code, message, e) => { result = message; waitHandle.Set(); });

            module.getSize(NetworkUri, promise);

            var timeout = !waitHandle.WaitOne(3000);

            if (timeout)
            {
                Assert.Inconclusive("Network timeout error.");
            }
            else
            {
                Assert.AreEqual(str, result);
            }
        }