Ejemplo n.º 1
0
        /// <summary>
        /// Creates a test isolation client.
        /// </summary>
        /// <param name="ipcPortName">The IPC port name.</param>
        /// <param name="linkId">The unique id of the client/server pair.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="ipcPortName"/> is null.</exception>
        public TestIsolationClient(string ipcPortName, Guid linkId)
        {
            if (ipcPortName == null)
                throw new ArgumentNullException("ipcPortName");

            this.linkId = linkId;

            clientChannel = new BinaryIpcClientChannel(ipcPortName);
            serverChannel = new BinaryIpcServerChannel(ipcPortName + ".ClientCallback");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a test isolation server.
        /// </summary>
        /// <param name="ipcPortName">The IPC port name.</param>
        /// <param name="linkId">The unique id of the client/server pair.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="ipcPortName"/> is null.</exception>
        public TestIsolationServer(string ipcPortName, Guid linkId)
        {
            if (ipcPortName == null)
                throw new ArgumentNullException("ipcPortName");

            serverChannel = new BinaryIpcServerChannel(ipcPortName);
            clientChannel = new BinaryIpcClientChannel(ipcPortName + ".ServerCallback");
            activeTasks = new Dictionary<Guid, IsolatedTaskState>();

            MessageConsumer messageConsumer = new MessageConsumer()
                .Handle<IsolatedTaskFinishedMessage>(HandleIsolatedTaskFinished);

            messageExchange = new MessageExchange(messageConsumer);
            serverChannel.RegisterService(GetMessageExchangeLinkServiceName(linkId), messageExchange);
        }
Ejemplo n.º 3
0
        public void RegisteredServiceCanBeAccessedWithGetService()
        {
            var hostFactory = (IsolatedAppDomainHostFactory)RuntimeAccessor.ServiceLocator.ResolveByComponentId(IsolatedAppDomainHostFactory.ComponentId);
            using (IHost host = hostFactory.CreateHost(new HostSetup(), new MarkupStreamLogger(TestLog.Default)))
            {
                HostAssemblyResolverHook.InstallCallback(host);

                host.GetHostService().Do<object, object>(RemoteCallback, null);

                using (BinaryIpcClientChannel clientChannel = new BinaryIpcClientChannel(PortName))
                {
                    TestService serviceProxy =
                        (TestService)clientChannel.GetService(typeof(TestService), ServiceName);
                    Assert.AreEqual(42, serviceProxy.Add(23, 19));
                }
            }
        }
 public void GetServiceThrowsIfServiceNameIsNull()
 {
     using (BinaryIpcClientChannel channel = new BinaryIpcClientChannel("port"))
         channel.GetService(typeof(int), null);
 }
 public void GetServiceThrowsIfServiceTypeIsNull()
 {
     using (BinaryIpcClientChannel channel = new BinaryIpcClientChannel("port"))
         channel.GetService(null, "service");
 }