예제 #1
0
 public void Test_Ctor_Overload_2()
 {
     using (DdeContext context = new DdeContext())
     {
         DdeServer server = new TestServer(ServiceName);
     }
 }
예제 #2
0
 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);
         }
     }
 }
예제 #3
0
 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));
         }
     }
 }
예제 #4
0
 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);
         }
     }
 }
예제 #5
0
 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);
         }
     }
 }
예제 #6
0
 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);
         }
     }
 }
예제 #7
0
 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));
         }
     }
 }
예제 #8
0
 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);
             }
         }
     }
 }
예제 #9
0
 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);
         }
     }
 }
예제 #10
0
 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);
         }
     }
 }
예제 #11
0
 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);
         }
     }
 }
예제 #12
0
 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);
         }
     }
 }
예제 #13
0
 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);
         }
     }
 }
예제 #14
0
 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);
         }
     }
 }
예제 #15
0
 public void Test_Disconnect_Before_Connect()
 {
     using (TestServer server = new TestServer(ServiceName))
     {
         server.Register();
         using (DdeClient client = new DdeClient(ServiceName, TopicName))
         {
             client.Disconnect();
         }
     }
 }
예제 #16
0
 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);
         }
     }
 }
예제 #17
0
 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();
         }
     }
 }
예제 #18
0
 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));
         }
     }
 }
예제 #19
0
 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);
         }
     }
 }
예제 #20
0
 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);
         }
     }
 }
예제 #21
0
 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);
         }
     }
 }
예제 #22
0
 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);
         }
     }
 }
예제 #23
0
 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);
         }
     }
 }
예제 #24
0
 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));
         }
     }
 }
예제 #25
0
 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)));
         }
     }
 }
예제 #26
0
 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);
         }
     }
 }
예제 #27
0
 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);
         }
     }
 }
예제 #28
0
 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);
         }
     }
 }
예제 #29
0
 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();
         }
     }
 }
예제 #30
0
 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));
         }
     }
 }