示例#1
0
        public void DoSyncSlaveSimpleTest()
        {
            using (SlaveManager currentSlaveManager = new SlaveManager()) {
                IIPCGUID slaveReceaverGUID = new IPCReceaverGUID(currentSlaveManager.LaunchSlave());
                // wait for slave is launched and ininialized;
                Thread.CurrentThread.Join(3000);
                using (BaseIPCDispatcher dispatcher = new BaseIPCDispatcher(slaveReceaverGUID)) {
                    TestSyncMessage test = new TestSyncMessage(dispatcher.Receaver);
                    test.StrIn   = "Hi Slave!";
                    test.TimeOut = SlaveResponces.SyncMessageSlaveDelay + 2000;
                    IPCDispatchResult dispatchResult = dispatcher.Dispatch(test);
                    Assert.IsTrue(dispatchResult == IPCDispatchResult.Success, "Unable to send message error because of the reason {0}", dispatchResult);
                    Assert.IsTrue(String.Equals(test.StrOut, SlaveResponces.TestSyncResponceString), "Time is up");
                }

                using (BaseIPCDispatcher dispatcher = new BaseIPCDispatcher(slaveReceaverGUID)) {
                    TestSyncMessage test = new TestSyncMessage(dispatcher.Receaver);
                    test.StrIn   = "Hi Slave!";
                    test.TimeOut = SlaveResponces.SyncMessageSlaveDelay - 2000;
                    IPCDispatchResult dispatchResult = dispatcher.Dispatch(test);
                    Assert.IsTrue(dispatchResult
                                  == IPCDispatchResult.Timeout, "Timeout is an expected but {0} is dispatch result", dispatchResult);
                }
            }
        }
示例#2
0
        public void DoReceaverNotExistsTest()
        {
            IIPCGUID receaverGUID = new IPCReceaverGUID(NonExistentPID);

            using (BaseIPCDispatcher dispatcher = new BaseIPCDispatcher(receaverGUID)) {
                TestAsyncMessage  test      = new TestAsyncMessage(receaverGUID);
                IPCDispatchResult tmpResult = dispatcher.Dispatch(test);
                Assert.IsTrue(tmpResult == IPCDispatchResult.ReceaverNotExists, "Receaver not exists but dispatch result is {0}", tmpResult);
            }
        }
示例#3
0
        public void DoInvalidMessageTest()
        {
            IIPCGUID receaverGUID = new IPCReceaverGUID();

            using (BaseIPCDispatcher dispatcher = new BaseIPCDispatcher(ReceaverHolder.GlobalApplicationReceaver.ReceaverID)) {
                TestInvalidMessage test      = new TestInvalidMessage(receaverGUID);
                IPCDispatchResult  tmpResult = dispatcher.Dispatch(test);
                Assert.IsTrue(tmpResult == IPCDispatchResult.InvalidMessageClass, "Receaver not exists but dispatch result is {0}", tmpResult);
            }
        }
        public void DoSyncSelfSimpleTest()
        {
            IIPCGUID receaverGUID = new IPCReceaverGUID();

            using (BaseIPCDispatcher dispatcher = new BaseIPCDispatcher(receaverGUID)) {
                TestSyncMessage test = new TestSyncMessage(receaverGUID);
                test.StrIn = TestMessageIn;
                Assert.IsTrue(dispatcher.Dispatch(test) == IPCDispatchResult.Success, "Unable to send message");
                Assert.IsTrue(TestMessageOut.Equals(test.StrOut), "Message is corrupted");
            }
        }
示例#5
0
 private static void ForwardResponce(IIPCMessage message, IIPCGUID receaver)
 {
     using (BaseIPCDispatcher dispatcher = new BaseIPCDispatcher(receaver)) {
         if (dispatcher.Dispatch(message) == IPCDispatchResult.Success)
         {
             Console.WriteLine("Message has been forwarded succesfully!");
         }
         else
         {
             Console.WriteLine("Unable to forward message");
         }
     }
 }
 public void DoAsyncComplexSlaveTest()
 {
     using (SlaveManager currentSlaveManager = new SlaveManager()) {
         IIPCGUID slaveReceaverGUID = new IPCReceaverGUID(currentSlaveManager.LaunchSlave());
         // wait for slave is launched and ininialized
         Thread.CurrentThread.Join(3000);
         using (BaseIPCDispatcher dispatcher = new BaseIPCDispatcher(slaveReceaverGUID)) {
             TestAsyncComplexMessage test = new TestAsyncComplexMessage(ReceaverHolder.GlobalApplicationReceaver.ReceaverID, null);
             Assert.IsTrue(dispatcher.Dispatch(test) == IPCDispatchResult.Success, "Unable to send message");
         }
         Thread.CurrentThread.Join(3000);
         Assert.IsTrue(responceFromSlaveReceaved, "Slave keep silence =(");
     }
 }