Пример #1
0
        public void EchoActorSendReceiveTests(string actorMessage)
        {
            EchoShimHandler echoShimHandler = new EchoShimHandler();
            Actor <string>  actor           = new Actor <string>(NetMQContext.Create(), echoShimHandler, "Hello World");

            actor.SendMore("ECHO");
            actor.Send(actorMessage);
            var    result = actor.ReceiveString();
            string expectedEchoHandlerResult = string.Format("ECHO BACK : {0}", actorMessage);

            Assert.AreEqual(expectedEchoHandlerResult, result);
            actor.Dispose();
        }
Пример #2
0
        public void BadCommandTests(string command)
        {
            string          actorMessage    = "whatever";
            EchoShimHandler echoShimHandler = new EchoShimHandler();
            Actor <string>  actor           = new Actor <string>(NetMQContext.Create(), echoShimHandler, "Hello World");

            actor.SendMore(command);
            actor.Send(actorMessage);
            var    result = actor.ReceiveString();
            string expectedEchoHandlerResult = "Error: invalid message to actor";

            Assert.AreEqual(expectedEchoHandlerResult, result);
            actor.Dispose();
        }
Пример #3
0
        public void BadStatePassedToActor(string stateForActor)
        {
            string          actorMessage    = "whatever";
            EchoShimHandler echoShimHandler = new EchoShimHandler();

            try
            {
                //this will throw in this testcase, asw are supplying bad state for this EchoHandler
                Actor <string> actor = new Actor <string>(NetMQContext.Create(), echoShimHandler, stateForActor);
            }
            catch (Exception e)
            {
                Assert.AreEqual("Args were not correct, expected 'Hello World'", e.Message);
            }
        }