Esempio n. 1
0
        public void CheckMessageProcessing()
        {
            using (MemoryStream ms = new MemoryStream())
            {
                // prep
                IpcMessage message = new IpcMessage()
                {
                    Service    = "IService",
                    Method     = "Sum",
                    Parameters = new object[] { 3, 5 }
                };

                IpcStream ipc = new IpcStream(ms, new List <Type>());

                ipc.WriteMessage(message);
                long startpos = ms.Position;
                ms.Seek(0, SeekOrigin.Begin);
                // ----


                Server s = new Server("testpipe");
                s.RegisterService <IService>(new Calculator());
                s.ProcessMessage(ipc, new Guid());


                // post
                ms.Seek(startpos, SeekOrigin.Begin);
                IpcMessage returnMessage = ipc.ReadMessage();

                var expectedMessage = new IpcMessage()
                {
                    Return = 8
                }.ToExpectedObject();

                expectedMessage.ShouldEqual(returnMessage);
            }
        }