예제 #1
0
 public void Test_BeginStartAdvise_Variation_2()
 {
     using var server = new TestServer(ServiceName);
     server.Register();
     server.SetData(TopicName, ItemName, 1, Encoding.ASCII.GetBytes(TestData));
     using var client = new DdeClient(ServiceName, TopicName);
     var listener = new EventListener();
     client.Advise += listener.OnEvent;
     client.Connect();
     var ar = client.BeginStartAdvise(ItemName, 1, false, null, null);
     Assert.IsTrue(ar.AsyncWaitHandle.WaitOne(Timeout, false));
     server.Advise(TopicName, ItemName);
     Assert.IsTrue(listener.Received.WaitOne(Timeout, false));
     var args = (DdeAdviseEventArgs) listener.Events[0];
     Assert.AreEqual(ItemName, args.Item);
     Assert.AreEqual(1, args.Format);
     Assert.IsNull(args.Data);
 }
예제 #2
0
 public void Test_StartAdvise_Variation_3()
 {
     using var server = new TestServer(ServiceName);
     server.Register();
     server.SetData(TopicName, ItemName, 1, Encoding.ASCII.GetBytes(TestData));
     using var client = new DdeClient(ServiceName, TopicName);
     var listener = new EventListener();
     client.Advise += listener.OnEvent;
     client.Connect();
     client.StartAdvise(ItemName, 1, true, true, Timeout, "MyStateObject");
     server.Advise(TopicName, ItemName);
     Assert.IsTrue(listener.Received.WaitOne(Timeout, false));
     var 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));
     Assert.AreEqual(TestData, args.Text);
 }
예제 #3
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));
         }
     }
 }
예제 #4
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));
         }
     }
 }
예제 #5
0
 public void Test_StartAdvise_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))
         {
             EventListener listener = new EventListener();
             client.Advise += listener.OnEvent;
             client.Connect();
             client.StartAdvise(ItemName, 1, false, 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.IsNull(args.Data);
             Assert.IsNull(args.Text);
         }
     }
 }