Ejemplo n.º 1
0
        public void VerifyCanPerformFunctionCallAfterBulk()
        {
            int numberKiloBytes = 1024 * 1024 * 1;
            var buffer = new byte[numberKiloBytes];
            for (int i = 0; i < numberKiloBytes; ++i)
            {
                buffer[i] = (byte)(i % 2);
            }

            var bulkDataStub = new BulkDataStub(buffer);

            var dispatcherThread = new DispatcherThread(Dispatcher.Run);
            dispatcherThread.Start();

            var ipcServer = new IpcServer<IBulkData>(bulkDataStub, dispatcherThread.Dispatcher, IPAddress.Loopback, 62000, new MsDataContractJsonSerializer());
            ipcServer.Listen();

            var ipcClient = new IpcClient<IBulkData>(IPAddress.Loopback, 62000, new MsDataContractJsonSerializer());

            ipcClient.Proxy.GetBulkyData();

            var fooResult = ipcClient.Proxy.Foo();
            Assert.AreEqual("Bar", fooResult);

            ipcClient.Dispose();
            ipcServer.Dispose();

            bulkDataStub.Dispose();

            dispatcherThread.Shutdown();
        }
Ejemplo n.º 2
0
        public void VerifyBulkyData_using_Json_dot_NET_serializer(int mb)
        {
            int numberKiloBytes = 1024 * 1024 * mb;
            var buffer = new byte[numberKiloBytes];
            for (int i = 0; i < numberKiloBytes; ++i)
            {
                buffer[i] = (byte)(i % 2);
            }

            var bulkDataStub = new BulkDataStub(buffer);
            var bulkDataHash = ComputeHash(bulkDataStub.GetBulkyData());

            var dispatcherThread = new DispatcherThread(Dispatcher.Run);
            dispatcherThread.Start();

            var ipcServer = new IpcServer<IBulkData>(bulkDataStub, dispatcherThread.Dispatcher, IPAddress.Loopback, 62000, new JsonDotNetSerializer());
            ipcServer.Listen();

            var ipcClient = new IpcClient<IBulkData>(IPAddress.Loopback, 62000, new JsonDotNetSerializer());

            Stream receivingStream = null;
            double ms = Performance.MeasureMs(() =>
            {
                receivingStream = ipcClient.Proxy.GetBulkyData();
            });

            var receivingHash = ComputeHash(receivingStream);
            Assert.That(receivingHash, Is.EqualTo(bulkDataHash));

            Console.WriteLine("Sending of {0}MB took {1}ms", mb, ms);

            ipcClient.Dispose();
            ipcServer.Dispose();

            bulkDataStub.Dispose();
            receivingStream.Dispose();

            dispatcherThread.Shutdown();
        }