Exemplo n.º 1
0
        public void DataAndTypeAreReadWriteInvariant()
        {
            var pipe = PipeName.New();

            var outbox = new []
            {
                BinaryMessage.Compose("Elm1", writer => { }),
                BinaryMessage.Compose("Elm1", writer => { }),
                BinaryMessage.Compose("Elm2", writer => writer.Write(new byte[] { 13, 37 })),
                BinaryMessage.Compose("Elm3", writer => writer.Write(new byte[] { 19, 11 })),
                BinaryMessage.Compose("Elm4", writer => { })
            };

            pipe.BeginWritingMessages("Test", ex => Assert.Fail("Write failed: " + ex.Message), outbox.ToObservable());

            var inbox = pipe.ReadMessages("test").RefCount().ToEnumerable().Take(outbox.Length).ToArray();

            Assert.AreEqual(outbox.Length, inbox.Length);

            for (int i = 0; i < outbox.Length; i++)
            {
                Assert.AreEqual(outbox[i].Type, inbox[i].Type);
                CollectionAssert.AreEqual(outbox[i].DumpBytes(), inbox[i].DumpBytes());
            }
        }
Exemplo n.º 2
0
        public static UnoHostProcess Spawn(AbsoluteFilePath assembly, IObservable <IBinaryMessage> messagesToUnoHost, AbsoluteFilePath userDataPath, IEnumerable <string> moreArgs)
        {
            if (Application == null)
            {
                throw new InvalidOperationException("UnoHostProcess.Application has not been initialized");
            }

            var args = new UnoHostArgs
            {
                AssemblyPath = assembly,
                OutputPipe   = PipeName.New(),
                InputPipe    = PipeName.New(),
                UserDataPath = userDataPath,
            };

            var disp = args.InputPipe.BeginWritingMessages("UnoHost", ex => Console.WriteLine("Designer failed to write message to UnoHost: " + ex), messagesToUnoHost);

            return(new UnoHostProcess
            {
                Messages = args.OutputPipe.ReadMessages("UnoHost"),
                Process = Observable.Start(() => Application.Start(args.Serialize().Concat(moreArgs))),
                Disposables = Disposable.Combine(disp)
            });
        }