public void Test_Ctor_Overload_2()
 {
     using (DdeContext context = new DdeContext())
     {
         DdeServer server = new TestServer(ServiceName);
     }
 }
 public void Test_Register_After_Register()
 {
     using (DdeServer server = new TestServer(ServiceName))
     {
         server.Register();
         server.Register();
     }
 }
 public void Test_Register()
 {
     using (DdeServer server = new TestServer(ServiceName))
     {
         server.Register();
         using (DdeClient client = new DdeClient(ServiceName, TopicName))
         {
             client.Connect();
         }
     }
 }
 public void Test_Connect_After_Dispose()
 {
     using (TestServer server = new TestServer(ServiceName))
     {
         server.Register();
         using (DdeClient client = new DdeClient(ServiceName, TopicName))
         {
             client.Dispose();
             client.Connect();
         }
     }
 }
 public void Test_Unregister()
 {
     using (DdeServer server = new TestServer(ServiceName))
     {
         server.Register();
         server.Unregister();
         using (DdeClient client = new DdeClient(ServiceName, TopicName))
         {
             try
             {
                 client.Connect();
                 Assert.Fail();
             }
             catch (DdeException e)
             {
                 Assert.AreEqual(0x400A, e.Code);
             }
         }
     }
 }
 public void Test_Request()
 {
     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 = client.Request(ItemName, 1, Timeout);
             Assert.AreEqual(TestData, Encoding.ASCII.GetString(data));
         }
     }
 }
 public void Test_IsRegistered_Variation_1()
 {
     using (DdeServer server = new TestServer(ServiceName))
     {
         Assert.IsFalse(server.IsRegistered);
     }
 }
 public void Test_Execute_TooBusy()
 {
     using (TestServer server = new TestServer(ServiceName))
     {
         server.Register();
         using (DdeClient client = new DdeClient(ServiceName, TopicName))
         {
             client.Connect();
             try 
             {
                 client.Execute("#TooBusy", Timeout);
             }
             catch (DdeException e)
             {
                 Assert.AreEqual(0x4001, e.Code);
             }
         }
     }
 }
 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_TransactionFilter()
 {
     using (DdeContext context = new DdeContext())
     {
         TransactionFilter filter = new TransactionFilter();
         context.AddTransactionFilter(filter);
         context.Initialize();
         using (DdeServer server = new TestServer(ServiceName))
         {
             server.Register();
         }
         Assert.IsTrue(filter.Received.WaitOne(Timeout, false));
     }
 }
 public void Test_BeginPoke_After_Dispose()
 {
     using (TestServer server = new TestServer(ServiceName))
     {
         server.Register();
         using (DdeClient client = new DdeClient(ServiceName, TopicName))
         {
             client.Connect();
             client.Dispose();
             IAsyncResult ar = client.BeginPoke(ItemName, Encoding.ASCII.GetBytes(TestData), 1, null, null);
         }
     }
 }
 public void Test_Service()
 {
     using (DdeServer server = new TestServer(ServiceName))
     {
         Assert.AreEqual(ServiceName, server.Service);
     }
 }
 public void Test_EndRequest_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.BeginRequest(ItemName, 1, null, null);
             Assert.IsTrue(ar.AsyncWaitHandle.WaitOne(Timeout, false));
             client.Dispose();
             byte[] data = client.EndRequest(ar);
         }
     }
 }
 public void Test_EndExecute_After_Dispose()
 {
     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));
             client.Dispose();
             client.EndExecute(ar);
         }
     }
 }
 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_BeginExecute_Before_Connect()
 {
     using (TestServer server = new TestServer(ServiceName))
     {
         server.Register();
         using (DdeClient client = new DdeClient(ServiceName, TopicName))
         {
             IAsyncResult ar = client.BeginExecute(TestData, null, null);
         }
     }
 }
 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_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_IsRegistered_Variation_2()
 {
     using (DdeServer server = new TestServer(ServiceName))
     {
         server.Register();
         Assert.IsTrue(server.IsRegistered);
     }
 }
 public void Test_TryRequest_Variation_1()
 {
     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;
             int result = client.TryRequest(ItemName, 1, Timeout, out data);
             Assert.AreNotEqual(0, result);
         }
     }
 }
 public void Test_Ctor_Overload_1()
 {
     DdeServer server = new TestServer(ServiceName);
 }
 public void Test_BeginRequest_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.BeginRequest(ItemName, 1, null, null);
         }
     }
 }
 public void Test_StartAdvise_Variation_1()
 {
     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();
             client.StartAdvise(ItemName, 1, true, Timeout);
             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(TestData, Encoding.ASCII.GetString(args.Data));
             Assert.AreEqual(TestData, args.Text);
         }
     }
 }
 public void Test_EndPoke()
 {
     using (TestServer server = new TestServer(ServiceName))
     {
         server.Register();
         using (DdeClient client = new DdeClient(ServiceName, TopicName))
         {
             client.Connect();
             IAsyncResult ar = client.BeginPoke(ItemName, Encoding.ASCII.GetBytes(TestData), 1, null, null);
             Assert.IsTrue(ar.AsyncWaitHandle.WaitOne(Timeout, false));
             client.EndPoke(ar);
             Assert.AreEqual(TestData, Encoding.ASCII.GetString(server.GetData(TopicName, ItemName, 1)));
         }
     }
 }
 public void Test_Unregister_Before_Register()
 {
     using (DdeServer server = new TestServer(ServiceName))
     {
         server.Unregister();
     }
 }
 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_Unregister_After_Dispose()
 {
     using (DdeServer server = new TestServer(ServiceName))
     {
         server.Register();
         server.Dispose();
         server.Unregister();
     }
 }
 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_Unregister()
 {
     using (DdeContext context = new DdeContext())
     {
         EventListener listener = new EventListener();
         context.Unregister += listener.OnEvent;
         context.Initialize();
         using (DdeServer server = new TestServer(ServiceName))
         {
             server.Register();
             server.Unregister();
         }
         Assert.IsTrue(listener.Received.WaitOne(Timeout, false));
     }
 }
 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);
         }
     }
 }