static void CreateConnection(Connection connection, EventWaitHandle modeChanged) { string error = null; connection.ConnectModeChanged += (sender, mode) => modeChanged.Set(); connection.ErrorOccured += (s,b) => { error = b.Exception.Message.ToString(); modeChanged.Set(); }; connection.QueueEmtpy += (sender, args) => { Console.WriteLine("Queue EMPTy"); }; var escx = "192.168.1.200"; var local = "127.0.0.1"; var usb = "COM4"; //connection.CreateConnection(local, ConnectType.Ethernet, ConnectMode.Install); connection.CreateConnection(usb, ConnectType.USB, ConnectMode.Install); modeChanged.WaitOne(); Assert.IsTrue(string.IsNullOrEmpty(error), error); Assert.IsTrue(connection.Mode == ConnectMode.Install, "Mode is: " + connection.Mode); }
public void SwitchModeTest() { var are = new AutoResetEvent(false); var exit = new AutoResetEvent(false); var z = new Connection(); string error = null; z.ConnectModeChanged += (sender, mode) => { Debug.WriteLine("Mode changed" + mode); if (mode.Mode == ConnectMode.Install) are.Set(); else exit.Set(); }; z.ErrorOccured += (o,message) => { Debug.WriteLine("Error occured"); error = message.Exception.Message.ToString(); are.Set(); }; for (int i = 0; i < 4; i++) { z.CreateConnection("127.0.0.1", ConnectType.Ethernet, ConnectMode.Install); are.WaitOne(); Assert.IsTrue(string.IsNullOrEmpty(error), error); Assert.IsTrue(z.Mode == ConnectMode.Install, "Mode is: " + z.Mode); z.Disconnect(); exit.WaitOne(); Assert.IsTrue(string.IsNullOrEmpty(error), error); Assert.IsTrue(z.Mode == ConnectMode.None, "Mode is: " + z.Mode); } }