public void Overrides_None()
        {
            ProxyFactory factory = new ProxyFactory();

            factory.Call <IMyService>(proxy =>
            {
                Assert.AreEqual("hi", proxy.TestMe("hi"));
            });
        }
Beispiel #2
0
        public void OverrideWithConfig_3()
        {
            var factory = new ProxyFactory();

            factory.Call <IMyService5>(proxy =>
            {
                Assert.AreEqual("hi", proxy.TestMe("hi"));
            });
        }
        public void BasicInProc_ForceInProc()
        {
            ProxyFactory factory = new ProxyFactory();

            factory.Call <IMyService>(proxy =>
            {
                Assert.AreEqual("hi", proxy.TestMe("hi"));
            });
        }
        public void BasicInProc_Simple()
        {
            ProxyFactory factory = new ProxyFactory();

            factory.Call <IMyService>(proxy =>
            {
                Assert.AreEqual("hi", proxy.TestMe("hi"));
            });
            Assert.AreEqual("hi", factory.Proxy <IMyService>().TestMe("hi"));
        }
Beispiel #5
0
        public void NoConfig_InProc()
        {
            ProxyFactory factory = new ProxyFactory();

            factory.Call <IMyService>(proxy =>
            {
                Assert.AreEqual("hi", proxy.TestMe("hi"));
            });
            Assert.AreEqual("hi", factory.Proxy <IMyService>().TestMe("hi"));
        }
        public void Overrides_Override()
        {
            ProxyFactory factory  = new ProxyFactory();
            MyService2   service2 = new MyService2();

            factory.AddProxyOverride <IMyService, MyService2>(service2);

            factory.Call <IMyService>(proxy =>
            {
                Assert.AreEqual("hello", proxy.TestMe("hi"));
            });
        }
        public void GenericInProc_Raw()
        {
            string uri = "net.tcp://localhost:10095/genericContractTCP";

            using (var host = new ServiceHost(typeof(GenericService), new Uri(uri)))
            {
                host.AddServiceEndpoint(typeof(IGenericContract), new NetTcpBinding(), uri);
                host.Open();

                var factory = new ProxyFactory();
                factory.Call <IGenericContract>(call =>
                {
                    Assert.AreEqual(10, call.Find(10));
                });
            }
        }
Beispiel #8
0
        public void Hosted_HTTP()
        {
            string uri = "http://localhost/servicehelpers";

            using (var host = new ServiceHost(typeof(ExternalService), new Uri(uri)))
            {
                host.AddServiceEndpoint(typeof(IExternalService), new WS2007HttpBinding(), uri);
                host.Open();

                var factory = new ProxyFactory();
                factory.Call <IExternalService>(call =>
                {
                    Assert.AreEqual("hi", call.TestMe("hi"));
                });
            }
        }
Beispiel #9
0
        public void Hosted_TCP()
        {
            string uri = "net.tcp://localhost:10095/servicehelpersTCP";

            using (var host = new ServiceHost(typeof(ExternalServiceTcp), new Uri(uri)))
            {
                host.AddServiceEndpoint(typeof(IExternalServiceTcp), new NetTcpBinding(), uri);
                host.Open();

                var factory = new ProxyFactory();
                factory.Call <IExternalServiceTcp>(call =>
                {
                    Assert.AreEqual("hi", call.TestMe("hi"));
                });
            }
        }
        public void Performance_InProc()
        {
            var factory = new ProxyFactory();

            factory.LogEnabled = false;

            var sw = new Stopwatch();

            MyService service2 = new MyService();

            service2.TestMe("Hi");

            sw.Reset();
            sw.Start();
            for (int i = 0; i < 10000; i++)
            {
                MyService service = new MyService();
                Assert.AreEqual("hi", service.TestMe("hi"));
            }
            sw.Stop();
            Trace.WriteLine("Native time = " + sw.ElapsedMilliseconds);

            factory.Call <IMyService>(proxy =>
            {
                proxy.TestMe("hi");
            });

            sw.Reset();
            sw.Start();
            for (int i = 0; i < 10000; i++)
            {
                factory.Call <IMyService>(proxy =>
                {
                    Assert.AreEqual("hi", proxy.TestMe("hi"));
                });
            }
            sw.Stop();
            Trace.WriteLine("Lambda time = " + sw.ElapsedMilliseconds);

            factory.Proxy <IMyService>().TestMe("hi");

            sw.Reset();
            sw.Start();
            for (int i = 0; i < 10000; i++)
            {
                Assert.AreEqual("hi", factory.Proxy <IMyService>().TestMe("hi"));
            }
            sw.Stop();
            Trace.WriteLine("Proxy time = " + sw.ElapsedMilliseconds);

            factory.Proxy <IProxyCached>().TestMe("hi");

            sw.Reset();
            sw.Start();
            for (int i = 0; i < 10000; i++)
            {
                Assert.AreEqual("hi", factory.Proxy <IProxyCached>().TestMe("hi"));
            }
            sw.Stop();
            Trace.WriteLine("Proxy Cached time = " + sw.ElapsedMilliseconds);
        }