示例#1
0
        public void TestRemoting()
        {
            using (RemoteTCPService <RemoteService> service =
                       new RemoteTCPService <RemoteService>(50315, "TestRemoting", WellKnownObjectMode.Singleton))
            {
                service.Connect();

                using (RemoteTCPClient <IRemoteService> client =
                           new RemoteTCPClient <IRemoteService>(new IPAddress(new byte[] { 127, 0, 0, 1 }), 50315, "TestRemoting"))
                {
                    client.Connect();

                    Assert.IsTrue(client.ServiceObject.Add(1.2d, 3.5d) == (1.2d + 3.5d), "Wrong add!");
                    Assert.IsTrue(client.ServiceObject.Sub(1.2d, 3.5d) == (1.2d - 3.5d), "Wrong add!");
                    Assert.IsTrue(client.ServiceObject.Div(1.2d, 3.5d) == (1.2d / 3.5d), "Wrong add!");
                    Assert.IsTrue(client.ServiceObject.Mul(1.2d, 3.5d) == (1.2d * 3.5d), "Wrong add!");

                    client.Disconnect();
                }

                service.Disconnect();
            }
        }
示例#2
0
        public void TestRemoting()
        {
            using (RemoteTCPService<RemoteService> service =
                   new RemoteTCPService<RemoteService>(50315, "TestRemoting", WellKnownObjectMode.Singleton))
            {
                service.Connect();

                using (RemoteTCPClient<IRemoteService> client =
                    new RemoteTCPClient<IRemoteService>(new IPAddress(new byte[] { 127, 0, 0, 1 }), 50315, "TestRemoting"))
                {
                    client.Connect();

                    Assert.IsTrue(client.ServiceObject.Add(1.2d, 3.5d) == (1.2d + 3.5d), "Wrong add!");
                    Assert.IsTrue(client.ServiceObject.Sub(1.2d, 3.5d) == (1.2d - 3.5d), "Wrong add!");
                    Assert.IsTrue(client.ServiceObject.Div(1.2d, 3.5d) == (1.2d / 3.5d), "Wrong add!");
                    Assert.IsTrue(client.ServiceObject.Mul(1.2d, 3.5d) == (1.2d * 3.5d), "Wrong add!");

                    client.Disconnect();
                }

                service.Disconnect();
            }
        }