Example #1
0
        public void UaTestSessionRecreate()
        {
            var client = new TestExtendUaClient(new Uri(ConfigurationManager.AppSettings["UATestEndpoint"]));

            client.Connect();
            var     i          = 0;
            Session oldSession = null;

            client.ServerConnectionLost += (object sender, EventArgs e) =>
            {
                if (i > 0)
                {
                    return;
                }
                i++;
                Assert.AreEqual(OpcStatus.NotConnected, client.Status);
                // store the session to make sure a new one is created
                oldSession = client.SessionExtended;
                client.RecreateSession();
                // put server back in good working order
                client.SessionExtended.OperationTimeout  = 200;
                client.SessionExtended.KeepAliveInterval = 100;
            };
            client.SessionExtended.OperationTimeout  = 0;
            client.SessionExtended.KeepAliveInterval = 10;
            Thread.Sleep(100);
            Assert.Greater(i, 0);
            // Give some time to call recreate
            Thread.Sleep(100);
            Assert.AreNotSame(oldSession, client.SessionExtended);
        }
Example #2
0
        public void UaTestKeepAliveNotifyDisconnect()
        {
            var client = new TestExtendUaClient(new Uri(ConfigurationManager.AppSettings["UATestEndpoint"]));

            client.Connect();
            var i = 0;

            client.ServerConnectionLost += (object sender, EventArgs e) =>
            {
                i++;
            };

            /* Basicallly kill server by not letting any
             * operations complete */
            client.SessionExtended.OperationTimeout = 0;
            // make sure sessionkeepalive executes at least once
            client.SessionExtended.KeepAliveInterval = 10;
            // give ample time to call sessionkeepalive
            Thread.Sleep(100);

            /* 'i' should only be one because SessionKeepAlive
             * only calls ServerConnectionLost if Status
             * is connected. Before it calls
             * ServerConnectionLost, it sets Status to
             * NotConnected */
            Assert.AreEqual(1, i);
        }
Example #3
0
        public void UaTestExtension()
        {
            var client = new TestExtendUaClient(new Uri(ConfigurationManager.AppSettings["UATestEndpoint"]));

            client.Connect();
            Assert.IsInstanceOf(typeof(Session), client.SessionExtended);
        }
Example #4
0
        public void UaTestReConnect()
        {
            var client = new TestExtendUaClient(new Uri(ConfigurationManager.AppSettings["UATestEndpoint"]));

            /* Should throw error because session should not be
             * initialized without calling connect */
            Assert.Throws <System.NullReferenceException>(() => client.ReConnect());
        }