예제 #1
0
 public void Test_Ctor_Overload_2()
 {
     using (DdeContext context = new DdeContext())
     {
         DdeServer server = new TestServer(ServiceName);
     }
 }
예제 #2
0
 public void Test_Register_After_Register()
 {
     using (DdeServer server = new TestServer(ServiceName))
     {
         server.Register();
         server.Register();
     }
 }
예제 #3
0
 public void Test_Register()
 {
     using (DdeServer server = new TestServer(ServiceName))
     {
         server.Register();
         using (DdeClient client = new DdeClient(ServiceName, TopicName))
         {
             client.Connect();
         }
     }
 }
예제 #4
0
 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();
         }
     }
 }
예제 #5
0
 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);
             }
         }
     }
 }
예제 #6
0
 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));
         }
     }
 }
예제 #7
0
 public void Test_IsRegistered_Variation_1()
 {
     using (DdeServer server = new TestServer(ServiceName))
     {
         Assert.IsFalse(server.IsRegistered);
     }
 }
예제 #8
0
 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);
             }
         }
     }
 }
예제 #9
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)));
         }
     }
 }
예제 #10
0
 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));
     }
 }
예제 #11
0
 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);
         }
     }
 }
예제 #12
0
 public void Test_Service()
 {
     using (DdeServer server = new TestServer(ServiceName))
     {
         Assert.AreEqual(ServiceName, server.Service);
     }
 }
예제 #13
0
 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);
         }
     }
 }
예제 #14
0
 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);
         }
     }
 }
예제 #15
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);
         }
     }
 }
예제 #16
0
 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);
         }
     }
 }
예제 #17
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);
         }
     }
 }
예제 #18
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);
         }
     }
 }
예제 #19
0
 public void Test_IsRegistered_Variation_2()
 {
     using (DdeServer server = new TestServer(ServiceName))
     {
         server.Register();
         Assert.IsTrue(server.IsRegistered);
     }
 }
예제 #20
0
 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);
         }
     }
 }
예제 #21
0
 public void Test_Ctor_Overload_1()
 {
     DdeServer server = new TestServer(ServiceName);
 }
예제 #22
0
 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);
         }
     }
 }
예제 #23
0
 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);
         }
     }
 }
예제 #24
0
 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)));
         }
     }
 }
예제 #25
0
 public void Test_Unregister_Before_Register()
 {
     using (DdeServer server = new TestServer(ServiceName))
     {
         server.Unregister();
     }
 }
예제 #26
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);
         }
     }
 }
예제 #27
0
 public void Test_Unregister_After_Dispose()
 {
     using (DdeServer server = new TestServer(ServiceName))
     {
         server.Register();
         server.Dispose();
         server.Unregister();
     }
 }
예제 #28
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);
         }
     }
 }
예제 #29
0
 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));
     }
 }
예제 #30
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);
         }
     }
 }