public void NetInfoModule_Event()
        {
            SetDispatcherForTest();

            var networkInterface = new MockNetworkListManager("None");
            var networkInfo      = new MockNetworkInformation(networkInterface);

            var emitted = new AutoResetEvent(false);
            var state   = default(JObject);
            var context = CreateReactContext(new MockInvocationHandler((name, args) =>
            {
                if (name == "emit" && args.Length == 2 && ((string)args[0]) == "networkStatusDidChange")
                {
                    state = (JObject)args[1];
                    emitted.Set();
                }
            }));

            var netInfo = new NetInfoModule(networkInfo, context);

            netInfo.Initialize();
            context.OnResume();

            networkInfo.networkListManager = new MockNetworkListManager("InternetAccess");
            networkInfo.OnNetworkAvailabilityChanged(new Guid(), NLM_CONNECTIVITY.NLM_CONNECTIVITY_IPV4_INTERNET);
            Assert.IsTrue(emitted.WaitOne());
            Assert.AreEqual(CreateNetworkInfo("InternetAccess"), state);
        }
예제 #2
0
        public void NetInfoModule_Event()
        {
            var networkInfo = new MockNetworkInformation();

            var emitted = new AutoResetEvent(false);
            var state   = default(JObject);
            var context = CreateReactContext(new MockInvocationHandler((name, args) =>
            {
                if (name == "emit" && args.Length == 2 && ((string)args[0]) == "networkStatusDidChange")
                {
                    state = (JObject)args[1];
                    emitted.Set();
                }
            }));

            var netInfo = new NetInfoModule(networkInfo, context);

            netInfo.Initialize();
            context.OnResume();

            networkInfo.CurrentConnectionProfile = new MockConnectionProfile(NetworkConnectivityLevel.InternetAccess);
            networkInfo.OnNetworkStatusChanged();
            Assert.IsTrue(emitted.WaitOne());
            Assert.AreEqual(CreateNetworkInfo("InternetAccess").ToString(Formatting.None), state.ToString(Formatting.None));
        }
예제 #3
0
        public void NetInfoModule_Event()
        {
            var networkInterface = new MockNetworkInterface("None");
            var networkInfo      = new MockNetworkInformation(networkInterface);

            var emitted = new AutoResetEvent(false);
            var state   = default(JObject);
            var context = CreateReactContext(new MockInvocationHandler((name, args) =>
            {
                if (name == "emit" && args.Length == 2 && ((string)args[0]) == "networkStatusDidChange")
                {
                    state = (JObject)args[1];
                    emitted.Set();
                }
            }));

            var netInfo = new NetInfoModule(networkInfo, context);

            netInfo.Initialize();
            context.OnResume();

            networkInfo.NetworkInterface = new MockNetworkInterface("InternetAccess");
            networkInfo.OnNetworkAvailabilityChanged(new object(), (NetworkAvailabilityEventArgs)null);
            Assert.IsTrue(emitted.WaitOne());
            Assert.AreEqual(CreateNetworkInfo("InternetAccess"), state);
        }
예제 #4
0
        public void NetInfoModule_LifecycleChecks()
        {
            var started = new AutoResetEvent(false);
            var stopped = new AutoResetEvent(false);

            var networkInfo = new MockNetworkInformation(
                () => started.Set(),
                () => stopped.Set());

            var context = CreateReactContext();
            var netInfo = new NetInfoModule(networkInfo, context);

            netInfo.Initialize();

            context.OnResume();
            Assert.IsTrue(started.WaitOne());

            context.OnSuspend();
            Assert.IsTrue(stopped.WaitOne());
        }