public void Test_Ctor_Overload_2() { using (DdeContext context = new DdeContext()) { DdeServer server = new TestServer(ServiceName); } }
public void Test_Execute_PauseConversation() { using (TestServer server = new TestServer(ServiceName)) { server.Register(); using (DdeClient client = new DdeClient(ServiceName, TopicName)) { client.Connect(); client.Execute("#PauseConversation", (int)server.Interval * 2); } } }
public void Test_BeginExecute() { using (TestServer server = new TestServer(ServiceName)) { server.Register(); using (DdeClient client = new DdeClient(ServiceName, TopicName)) { client.Connect(); IAsyncResult ar = client.BeginExecute(TestData, null, null); Assert.IsTrue(ar.AsyncWaitHandle.WaitOne(Timeout, false)); } } }
public void Test_BeginExecute_After_Dispose() { using (TestServer server = new TestServer(ServiceName)) { server.Register(); using (DdeClient client = new DdeClient(ServiceName, TopicName)) { client.Connect(); client.Dispose(); IAsyncResult ar = client.BeginExecute(TestData, null, null); } } }
public void Test_Execute() { using (TestServer server = new TestServer(ServiceName)) { server.Register(); using (DdeClient client = new DdeClient(ServiceName, TopicName)) { client.Connect(); client.Execute(CommandText, Timeout); Assert.AreEqual(CommandText, server.Command); } } }
public void Test_Abandon_After_Dispose() { using (TestServer server = new TestServer(ServiceName)) { server.Register(); using (DdeClient client = new DdeClient(ServiceName, TopicName)) { client.Connect(); client.Pause(); IAsyncResult ar = client.BeginExecute(CommandText, null, null); client.Dispose(); client.Abandon(ar); } } }
public void Test_Abandon() { using (TestServer server = new TestServer(ServiceName)) { server.Register(); using (DdeClient client = new DdeClient(ServiceName, TopicName)) { client.Connect(); client.Pause(); IAsyncResult ar = client.BeginExecute(CommandText, null, null); Assert.IsFalse(ar.AsyncWaitHandle.WaitOne(Timeout, false)); client.Abandon(ar); client.Resume(); Assert.IsFalse(ar.AsyncWaitHandle.WaitOne(Timeout, false)); } } }
public void Test_Execute_NotProcessed() { using (TestServer server = new TestServer(ServiceName)) { server.Register(); using (DdeClient client = new DdeClient(ServiceName, TopicName)) { client.Connect(); try { client.Execute("#NotProcessed", Timeout); } catch (DdeException e) { Assert.AreEqual(0x4009, e.Code); } } } }
public void Test_IsConnected_Variation_2() { using (TestServer server = new TestServer(ServiceName)) { server.Register(); using (DdeClient client = new DdeClient(ServiceName, TopicName)) { client.Connect(); Assert.IsTrue(client.IsConnected); } } }
public void Test_Handle_Variation_3() { using (TestServer server = new TestServer(ServiceName)) { server.Register(); using (DdeClient client = new DdeClient(ServiceName, TopicName)) { client.Connect(); client.Disconnect(); Assert.AreEqual(IntPtr.Zero, client.Handle); } } }
public void Test_TryExecute_Variation_2() { using (TestServer server = new TestServer(ServiceName)) { server.Register(); using (DdeClient client = new DdeClient(ServiceName, TopicName)) { client.Connect(); int result = client.TryExecute(TestData, Timeout); Assert.AreEqual(0, result); Assert.AreEqual(TestData, server.Command); } } }
public void Test_BeginPoke_Before_Connect() { using (TestServer server = new TestServer(ServiceName)) { server.Register(); using (DdeClient client = new DdeClient(ServiceName, TopicName)) { IAsyncResult ar = client.BeginPoke(ItemName, Encoding.ASCII.GetBytes(TestData), 1, null, null); } } }
public void Test_Request_Overload_2() { using (TestServer server = new TestServer(ServiceName)) { server.Register(); server.SetData(TopicName, ItemName, 1, Encoding.ASCII.GetBytes(TestData)); using (DdeClient client = new DdeClient(ServiceName, TopicName)) { client.Connect(); string data = client.Request(ItemName, Timeout); Assert.AreEqual(TestData, data); } } }
public void Test_Poke_Before_Connect() { using (TestServer server = new TestServer(ServiceName)) { server.Register(); using (DdeClient client = new DdeClient(ServiceName, TopicName)) { client.Poke(ItemName, Encoding.ASCII.GetBytes(TestData), 1, Timeout); } } }
public void Test_Disconnect_Before_Connect() { using (TestServer server = new TestServer(ServiceName)) { server.Register(); using (DdeClient client = new DdeClient(ServiceName, TopicName)) { client.Disconnect(); } } }
public void Test_Disconnected_Variation_3() { using (TestServer server = new TestServer(ServiceName)) { server.Register(); using (DdeClient client = new DdeClient(ServiceName, TopicName)) { EventListener listener = new EventListener(); client.Disconnected += listener.OnEvent; client.Connect(); client.Dispose(); Assert.IsTrue(listener.Received.WaitOne(Timeout, false)); DdeDisconnectedEventArgs args = (DdeDisconnectedEventArgs)listener.Events[0]; Assert.IsFalse(args.IsServerInitiated); Assert.IsTrue(args.IsDisposed); } } }
public void Test_Connect_After_Connect() { using (TestServer server = new TestServer(ServiceName)) { server.Register(); using (DdeClient client = new DdeClient(ServiceName, TopicName)) { client.Connect(); client.Connect(); } } }
public void Test_BeginStartAdvise_Variation_3() { using (TestServer server = new TestServer(ServiceName)) { server.Register(); server.SetData(TopicName, ItemName, 1, Encoding.ASCII.GetBytes(TestData)); using (DdeClient client = new DdeClient(ServiceName, TopicName)) { EventListener listener = new EventListener(); client.Advise += listener.OnEvent; client.Connect(); IAsyncResult ar = client.BeginStartAdvise(ItemName, 1, true, true, null, null, "MyStateObject"); Assert.IsTrue(ar.AsyncWaitHandle.WaitOne(Timeout, false)); server.Advise(TopicName, ItemName); Assert.IsTrue(listener.Received.WaitOne(Timeout, false)); DdeAdviseEventArgs args = (DdeAdviseEventArgs)listener.Events[0]; Assert.AreEqual(ItemName, args.Item); Assert.AreEqual(1, args.Format); Assert.AreEqual("MyStateObject", args.State); Assert.AreEqual(TestData, Encoding.ASCII.GetString(args.Data)); } } }
public void Test_BeginStartAdvise_Before_Connect() { using (TestServer server = new TestServer(ServiceName)) { server.Register(); server.SetData(TopicName, ItemName, 1, Encoding.ASCII.GetBytes(TestData)); using (DdeClient client = new DdeClient(ServiceName, TopicName)) { IAsyncResult ar = client.BeginStartAdvise(ItemName, 1, false, null, null); } } }
public void Test_BeginRequest_After_Dispose() { using (TestServer server = new TestServer(ServiceName)) { server.Register(); server.SetData(TopicName, ItemName, 1, Encoding.ASCII.GetBytes(TestData)); using (DdeClient client = new DdeClient(ServiceName, TopicName)) { client.Connect(); client.Dispose(); IAsyncResult ar = client.BeginRequest(ItemName, 1, null, null); } } }
public void Test_IsConnected_Variation_4() { using (TestServer server = new TestServer(ServiceName)) { server.Register(); using (DdeClient client = new DdeClient(ServiceName, TopicName)) { EventListener listener = new EventListener(); client.Disconnected += listener.OnEvent; client.Connect(); server.Disconnect(); Assert.IsTrue(listener.Received.WaitOne(Timeout, false)); Assert.IsFalse(client.IsConnected); } } }
public void Test_TryPoke_Variation_1() { using (TestServer server = new TestServer(ServiceName)) { server.Register(); using (DdeClient client = new DdeClient(ServiceName, TopicName)) { int result = client.TryPoke(ItemName, Encoding.ASCII.GetBytes(TestData), 1, Timeout); Assert.AreNotEqual(0, result); } } }
public void Test_IsPaused_Variation_3() { using (TestServer server = new TestServer(ServiceName)) { server.Register(); using (DdeClient client = new DdeClient(ServiceName, TopicName)) { client.Connect(); client.Pause(); client.Resume(); Assert.IsFalse(client.IsPaused); } } }
public void Test_EndRequest() { using (TestServer server = new TestServer(ServiceName)) { server.Register(); server.SetData(TopicName, ItemName, 1, Encoding.ASCII.GetBytes(TestData)); using (DdeClient client = new DdeClient(ServiceName, TopicName)) { client.Connect(); IAsyncResult ar = client.BeginRequest(ItemName, 1, null, null); Assert.IsTrue(ar.AsyncWaitHandle.WaitOne(Timeout, false)); byte[] data = client.EndRequest(ar); Assert.AreEqual(TestData, Encoding.ASCII.GetString(data)); } } }
public void Test_Poke() { using (TestServer server = new TestServer(ServiceName)) { server.Register(); using (DdeClient client = new DdeClient(ServiceName, TopicName)) { client.Connect(); client.Poke(ItemName, Encoding.ASCII.GetBytes(TestData), 1, Timeout); Assert.AreEqual(TestData, Encoding.ASCII.GetString(server.GetData(TopicName, ItemName, 1))); } } }
public void Test_EndStartAdvise_After_Dispose() { using (TestServer server = new TestServer(ServiceName)) { server.Register(); server.SetData(TopicName, ItemName, 1, Encoding.ASCII.GetBytes(TestData)); using (DdeClient client = new DdeClient(ServiceName, TopicName)) { client.Connect(); IAsyncResult ar = client.BeginStartAdvise(ItemName, 1, true, null, null); Assert.IsTrue(ar.AsyncWaitHandle.WaitOne(Timeout, false)); client.Dispose(); client.EndStartAdvise(ar); } } }
public void Test_Request_Before_Connect() { using (TestServer server = new TestServer(ServiceName)) { server.Register(); server.SetData(TopicName, ItemName, 1, Encoding.ASCII.GetBytes(TestData)); using (DdeClient client = new DdeClient(ServiceName, TopicName)) { byte[] data = client.Request(ItemName, 1, Timeout); } } }
public void Test_Execute_Before_Connect() { using (TestServer server = new TestServer(ServiceName)) { server.Register(); using (DdeClient client = new DdeClient(ServiceName, TopicName)) { client.Execute(TestData, Timeout); } } }
public void Test_Resume_After_Dispose() { using (TestServer server = new TestServer(ServiceName)) { server.Register(); using (DdeClient client = new DdeClient(ServiceName, TopicName)) { client.Connect(); client.Pause(); client.Dispose(); client.Resume(); } } }
public void Test_TryRequest_Variation_2() { using (TestServer server = new TestServer(ServiceName)) { server.Register(); server.SetData(TopicName, ItemName, 1, Encoding.ASCII.GetBytes(TestData)); using (DdeClient client = new DdeClient(ServiceName, TopicName)) { client.Connect(); byte[] data; int result = client.TryRequest(ItemName, 1, Timeout, out data); Assert.AreEqual(0, result); Assert.AreEqual(TestData, Encoding.ASCII.GetString(data)); } } }