public async void TestSendAndReceiveWithPoller()
        {
            var resolver = new DependencyResolver();

            using (var broker = new ZmqPollBroker(this.zmqContext, ClientInboundAddress, ServerInboundAddress))
            {
                broker.Listen();

                using (var server = new ZmqPollServer(this.zmqContext, ServerInboundAddress, new ServiceFactory(resolver)))
                {
                    server.Listen();

                    using (var client = new ZmqPollClient(this.zmqContext, ClientInboundAddress))
                    {
                        var clientFactory = new ServiceClientFactory(client);

                        var serviceClient = clientFactory.CreateServiceClient <ITestService2>();

                        Assert.That(serviceClient.GetPerson(1), Is.Not.Null);

                        var persons = await serviceClient.ListPersonsAsync(5);

                        Assert.That(persons, Is.Not.Null);
                        Assert.AreEqual(5, persons.Count());

                        var nullCollection = await serviceClient.ListPersonsAsync(-1);

                        Assert.IsNull(nullCollection);

                        var nullObject = serviceClient.GetPerson(-1);
                        Assert.IsNull(nullObject);
                    }
                }
            }
        }
Example #2
0
        public async void RequestGetsResponseFromServer()
        {
            var clientFactory = new ServiceClientFactory(new SimpleClient(new ServiceFactory(this.resolver)));

            var serviceClient = clientFactory.CreateServiceClient <ITestService2>();

            //Synchronous
            Assert.That(serviceClient.GetPerson(1), Is.Not.Null);

            //Asynchronous task based
            var persons = await serviceClient.ListPersonsAsync(5);

            Assert.That(persons, Is.Not.Null);
            Assert.AreEqual(5, persons.Count());

            //Asynchronous IAsyncResult based , awaiting with Task
            var person = await Task.Factory.FromAsync <int, Person>(serviceClient.BeginGetPerson, serviceClient.EndGetPerson, 1, null);

            Assert.That(person, Is.Not.Null);

            var nullCollection = await serviceClient.ListPersonsAsync(-1);

            Assert.IsNull(nullCollection);

            var nullObject = serviceClient.GetPerson(-1);

            Assert.IsNull(nullObject);
        }
Example #3
0
        static void Main(string[] args)
        {
            var logger = new LoggerStub();

            // using (var logger = new ConsoleLoggerWrapper(new LoggerStub()))
            // {
            Helpers.LogCurrentMemoryUsage(logger);
            // Console.ReadLine();

            var messagePackSerializerFactory = new MessagePackSerializerFactory();

            using (var testServiceClient = ServiceClientFactory.CreateServiceClient <ITestService>(
                       "localhost",
                       logger,
                       messagePackSerializerFactory))
            {
                using (var wcfTestServiceClient = CommonWcfComponents.ServiceClient <ITestService> .Create())
                {
                    Console.WriteLine("Test service client created.");

                    RunTest(wcfTestServiceClient.Service, logger);

                    Helpers.LogCurrentMemoryUsage(logger);

                    Console.WriteLine("All requests send.");
                    Console.ReadLine();
                }
            }
            // }
        }
        public async void RequestGetsResponseFromServer()
        {
            var clientFactory = new ServiceClientFactory(new SimpleClient(new ServiceFactory(this.resolver)));

            var serviceClient = clientFactory.CreateServiceClient<ITestService2>();

            //Synchronous
            Assert.That(serviceClient.GetPerson(1), Is.Not.Null);

            //Asynchronous task based
            var persons = await serviceClient.ListPersonsAsync(5);

            Assert.That(persons, Is.Not.Null);
            Assert.AreEqual(5, persons.Count());

            //Asynchronous IAsyncResult based , awaiting with Task
            var person = await Task.Factory.FromAsync<int, Person>(serviceClient.BeginGetPerson, serviceClient.EndGetPerson, 1, null);
            Assert.That(person, Is.Not.Null);

            var nullCollection = await serviceClient.ListPersonsAsync(-1);
            Assert.IsNull(nullCollection);

            var nullObject = serviceClient.GetPerson(-1);
            Assert.IsNull(nullObject);
        }
Example #5
0
        static void Main(string[] args)
        {
            var logger = new LoggerStub();

            Helpers.LogCurrentMemoryUsage(logger);

            var serviceClientFactory = new ServiceClientFactory(logger);

            using (var testServiceClient = serviceClientFactory.CreateServiceClient <ITestService>(
                       "localhost"))
            {
                Console.WriteLine("Test service client created.");

                // Warm up
                const int warmUpCallsCount = 5000;
                Enumerable
                .Range(0, warmUpCallsCount)
                .ParallelForEach(_ => SendRequestAndLogResult(testServiceClient.ServiceInstance, logger));

                Console.WriteLine("Warmup done");
                GC.Collect(2, GCCollectionMode.Forced);
                // Thread.Sleep(TimeSpan.FromSeconds(5));

                const int callsCount = 10000;
                RunTests(() => TestAsyncOperations(testServiceClient.ServiceInstance, logger, callsCount), logger);
                Console.WriteLine("All requests send.");
                Console.ReadLine();
            }
        }
Example #6
0
        public void CanCreateClient()
        {
            var factory = new ServiceClientFactory(new Mock<IClient>().Object);

            var serviceClient = factory.CreateServiceClient<ITestService>();
            Assert.That(serviceClient, Is.Not.Null);
        }
        public async void TestSendAndReceiveWithPoller()
        {
            var resolver = new DependencyResolver();

            using (var broker = new ZmqPollBroker(this.zmqContext, ClientInboundAddress, ServerInboundAddress))
            {
                broker.Listen();

                using (var server = new ZmqPollServer(this.zmqContext, ServerInboundAddress, new ServiceFactory(resolver)))
                {
                    server.Listen();

                    using (var client = new ZmqPollClient(this.zmqContext, ClientInboundAddress))
                    {
                        var clientFactory = new ServiceClientFactory(client);

                        var serviceClient = clientFactory.CreateServiceClient<ITestService2>();

                        Assert.That(serviceClient.GetPerson(1), Is.Not.Null);

                        var persons = await serviceClient.ListPersonsAsync(5);
                        Assert.That(persons, Is.Not.Null);
                        Assert.AreEqual(5, persons.Count());

                        var nullCollection = await serviceClient.ListPersonsAsync(-1);
                        Assert.IsNull(nullCollection);

                        var nullObject = serviceClient.GetPerson(-1);
                        Assert.IsNull(nullObject);
                    }
                }
            }
        }
Example #8
0
        public async void AsyncClientMethodsTest()
        {
            var serializerFactory    = new MessagePackSerializerFactory();
            var serviceClientFactory = new ServiceClientFactory(new LoggerStub());

            using (var _ = GetTestService(serializerFactory))
            {
                using (var client = serviceClientFactory.CreateServiceClient <ITestService>(
                           "localhost",
                           serializerFactory))
                {
                    var myHashcode = await client.ServiceInstance.GetHashCodeOfMeAsync(SerializableObject.GetTestInstance());

                    Assert.Equal(SerializableObject.TestInt, myHashcode);

                    var constructedObject = await client.ServiceInstance.ConstructObjectAsync(
                        SerializableObject.TestInt,
                        SerializableObject.TestString,
                        SerializableObject.TestDouble);

                    Assert.NotNull(constructedObject);
                    Assert.Equal(SerializableObject.TestInt, constructedObject.IntProperty);
                    Assert.Equal(SerializableObject.TestString, constructedObject.StringProperty);
                    Assert.Equal(SerializableObject.TestDouble, constructedObject.NestedObject.DoubleProperty);

                    var(count, objects) = await client.ServiceInstance.GetObjectsAsync(1, 1);

                    Assert.Equal(2, count);
                    constructedObject = objects.Single();
                    Assert.Equal(SerializableObject.TestInt, constructedObject.IntProperty);
                    Assert.Equal(SerializableObject.TestString, constructedObject.StringProperty);
                    Assert.Equal(SerializableObject.TestDouble, constructedObject.NestedObject.DoubleProperty);
                }
            }
        }
        public void CanCreateClient()
        {
            var factory = new ServiceClientFactory(new Mock <IClient>().Object);

            var serviceClient = factory.CreateServiceClient <ITestService>();

            Assert.That(serviceClient, Is.Not.Null);
        }
Example #10
0
        public void CanHandleTimeouts()
        {
            var clientMock = new Mock <IClient>();

            this.SetupClient(clientMock, 1000); //takes 100ms to reply

            var factory       = new ServiceClientFactory(clientMock.Object);
            var serviceClient = factory.CreateServiceClient <ITestService>(50); //50ms timeout

            Assert.Throws <TimeoutException>(() => serviceClient.Sum(10, 5));
        }
Example #11
0
        /// <summary>
        /// Handles ClientConnected event of _scsServer object.
        /// </summary>
        /// <param name="sender">Source of event</param>
        /// <param name="e">Event arguments</param>
        private void ScsServer_ClientConnected(object sender, ServerClientEventArgs e)
        {
            var requestReplyMessenger = new RequestReplyMessenger <IServerClient>(e.Client);

            requestReplyMessenger.MessageReceived += Client_MessageReceived;
            requestReplyMessenger.Start();

            var serviceClient = ServiceClientFactory.CreateServiceClient(e.Client, requestReplyMessenger);

            _serviceClients[serviceClient.ClientId] = serviceClient;
            OnClientConnected(serviceClient);
        }
Example #12
0
        public void CanUseClientWithNonComplexTypes()
        {
            var clientMock = new Mock<IClient>();
            this.SetupClient(clientMock);

            var factory = new ServiceClientFactory(clientMock.Object);
            var serviceClient = factory.CreateServiceClient<ITestService>();

            var sum = serviceClient.Sum(10, 5);
            Assert.That(sum, Is.EqualTo(15));

            var concatenated = serviceClient.Concatenate("10", "01");
            Assert.That(concatenated.Result, Is.EqualTo("1001"));

        }
Example #13
0
        public void CanUseClientWithNonComplexTypes()
        {
            var clientMock = new Mock <IClient>();

            this.SetupClient(clientMock);

            var factory       = new ServiceClientFactory(clientMock.Object);
            var serviceClient = factory.CreateServiceClient <ITestService>();

            var sum = serviceClient.Sum(10, 5);

            Assert.That(sum, Is.EqualTo(15));

            var concatenated = serviceClient.Concatenate("10", "01");

            Assert.That(concatenated.Result, Is.EqualTo("1001"));
        }
Example #14
0
        /// <summary>
        /// Creates an instance with specified endpoint, credential information and credential information.
        /// </summary>
        /// <param name="endpoint">OSS endpoint</param>
        /// <param name="credsProvider">Credentials information</param>
        /// <param name="configuration">client side configuration</param>
        public OssClient(Uri endpoint, ICredentialsProvider credsProvider, ClientConfiguration configuration)
        {
            if (endpoint == null)
            {
                throw new ArgumentException(Resources.ExceptionIfArgumentStringIsNullOrEmpty, "endpoint");
            }

            if (!endpoint.ToString().StartsWith("http://", StringComparison.OrdinalIgnoreCase) &&
                !endpoint.ToString().StartsWith("https://", StringComparison.OrdinalIgnoreCase))
            {
                throw new ArgumentException(OssResources.EndpointNotSupportedProtocal, "endpoint");
            }

            _endpoint      = endpoint;
            _credsProvider = credsProvider ?? throw new ArgumentException(Resources.ExceptionIfArgumentStringIsNullOrEmpty, "credsProvider");
            _serviceClient = ServiceClientFactory.CreateServiceClient(configuration ?? new ClientConfiguration());
        }
        //[TestCase(5, 1000000)]
        public async void TestLoadBalancingWithPoll(int nServers, int nMsgs)
        {
            var resolver = new DependencyResolver();

            using (var broker = new ZmqPollBroker(this.zmqContext, ClientInboundAddress, ServerInboundAddress))
            {
                broker.Listen();

                var servers = Enumerable.Range(0, nServers)
                              .Select(i => new ZmqPollServer(this.zmqContext, ServerInboundAddress, new ServiceFactory(resolver)))
                              .ToArray();

                try
                {
                    foreach (var server in servers)
                    {
                        server.Listen();
                    }

                    using (var client = new ZmqPollClient(this.zmqContext, ClientInboundAddress))
                    {
                        var clientFactory = new ServiceClientFactory(client);

                        var serviceClient = clientFactory.CreateServiceClient <ITestService2>();

                        var tasks = Enumerable.Range(0, nMsgs)
                                    //.Select(i => serviceClient.SumAsync(5, 15))
                                    .Select(i => serviceClient.ListPersonsAsync(7))
                                    .ToArray();

                        await Task.WhenAll(tasks);

                        Assert.True(tasks.All(t => t.Result.Count() == 7));
                    }
                }
                finally
                {
                    foreach (var server in servers)
                    {
                        server.Dispose();
                    }
                }
            }
        }
        public async void TestSendAndReceiveExceptions()
        {
            var resolver = new DependencyResolver();

            using (var broker = new ZmqBroker(this.zmqContext, ClientInboundAddress, ClientOutboundAddress, ServerInboundAddress, ServerOutboundAddress))
            {
                broker.Listen();

                using (var server = new ZmqServer(this.zmqContext, ServerInboundAddress, ServerOutboundAddress, new ServiceFactory(resolver)))
                {
                    server.Listen();

                    using (var client = new ZmqClient(this.zmqContext, ClientInboundAddress, ClientOutboundAddress))
                    {
                        var clientFactory = new ServiceClientFactory(client);

                        var serviceClient = clientFactory.CreateServiceClient <ITestService>();

                        //Synchronous
                        var err = Assert.Catch(async() => await serviceClient.FailAsync());
                        Assert.IsNotNull(err);
                        Assert.IsNotInstanceOf <AggregateException>(err);

                        //Asynchronous task based
                        err = Assert.Catch(() => serviceClient.Fail());
                        Assert.IsNotNull(err);
                        Assert.IsNotInstanceOf <AggregateException>(err);

                        //Asynchronous IAsyncResult based , awaiting with Task
                        err = Assert.Catch(async() => await Task.Factory.FromAsync(serviceClient.BeginFail, serviceClient.EndFail, null));
                        Assert.IsNotNull(err);
                        Assert.IsNotInstanceOf <AggregateException>(err);

                        //Timeout exceptions
                        var factoryWithTimeout       = new ServiceClientFactory(client);
                        var serviceClientWithTimeout = factoryWithTimeout.CreateServiceClient <ITestService>(50); //50ms

                        Assert.Throws <TimeoutException>(async() => await serviceClientWithTimeout.ReplyAfter(1000));
                    }
                }
            }
        }
        public async void TestSendAndReceiveExceptions()
        {
            var resolver = new DependencyResolver();

            using (var broker = new ZmqBroker(this.zmqContext, ClientInboundAddress, ClientOutboundAddress, ServerInboundAddress, ServerOutboundAddress))
            {
                broker.Listen();

                using (var server = new ZmqServer(this.zmqContext, ServerInboundAddress, ServerOutboundAddress, new ServiceFactory(resolver)))
                {
                    server.Listen();

                    using (var client = new ZmqClient(this.zmqContext, ClientInboundAddress, ClientOutboundAddress))
                    {
                        var clientFactory = new ServiceClientFactory(client);

                        var serviceClient = clientFactory.CreateServiceClient<ITestService>();

                        //Synchronous
                        var err = Assert.Catch(async () => await serviceClient.FailAsync());
                        Assert.IsNotNull(err);
                        Assert.IsNotInstanceOf<AggregateException>(err);

                        //Asynchronous task based
                        err = Assert.Catch(() => serviceClient.Fail());
                        Assert.IsNotNull(err);
                        Assert.IsNotInstanceOf<AggregateException>(err);

                        //Asynchronous IAsyncResult based , awaiting with Task
                        err = Assert.Catch(async () => await Task.Factory.FromAsync(serviceClient.BeginFail, serviceClient.EndFail, null));
                        Assert.IsNotNull(err);
                        Assert.IsNotInstanceOf<AggregateException>(err);

                        //Timeout exceptions
                        var factoryWithTimeout = new ServiceClientFactory(client);
                        var serviceClientWithTimeout = factoryWithTimeout.CreateServiceClient<ITestService>(50); //50ms

                        Assert.Throws<TimeoutException>(async () => await serviceClientWithTimeout.ReplyAfter(1000));
                    }
                }
            }
        }
        public void RequestGetsExceptionFromServer()
        {
            var clientFactory = new ServiceClientFactory(new SimpleClient(new ServiceFactory(this.resolver)));

            var serviceClient = clientFactory.CreateServiceClient<ITestService>();

            //Synchronous
            var err = Assert.Catch(async () => await serviceClient.FailAsync());
            Assert.IsNotNull(err);
            Assert.IsNotInstanceOf<AggregateException>(err);

            //Asynchronous task based
            err = Assert.Catch(() => serviceClient.Fail());
            Assert.IsNotNull(err);
            Assert.IsNotInstanceOf<AggregateException>(err);

            //Asynchronous IAsyncResult based , awaiting with Task
            err = Assert.Catch(async () => await Task.Factory.FromAsync(serviceClient.BeginFail, serviceClient.EndFail, null));
            Assert.IsNotNull(err);
            Assert.IsNotInstanceOf<AggregateException>(err);
        }
Example #19
0
        public void RequestGetsExceptionFromServer()
        {
            var clientFactory = new ServiceClientFactory(new SimpleClient(new ServiceFactory(this.resolver)));

            var serviceClient = clientFactory.CreateServiceClient <ITestService>();

            //Synchronous
            var err = Assert.Catch(async() => await serviceClient.FailAsync());

            Assert.IsNotNull(err);
            Assert.IsNotInstanceOf <AggregateException>(err);

            //Asynchronous task based
            err = Assert.Catch(() => serviceClient.Fail());
            Assert.IsNotNull(err);
            Assert.IsNotInstanceOf <AggregateException>(err);

            //Asynchronous IAsyncResult based , awaiting with Task
            err = Assert.Catch(async() => await Task.Factory.FromAsync(serviceClient.BeginFail, serviceClient.EndFail, null));
            Assert.IsNotNull(err);
            Assert.IsNotInstanceOf <AggregateException>(err);
        }
        //[TestCase(5, 1000000)]
        public async void TestLoadBalancing(int nServers, int nMsgs)
        {
            var resolver = new DependencyResolver();

            var servers = Enumerable.Range(0, nServers)
                          .Select(i => new RedisServer(new RedisConnection(RedisHost, RedisPort, RedisPassword), ServerQueue, new ServiceFactory(resolver)))
                          .ToArray();

            try
            {
                foreach (var server in servers)
                {
                    server.Listen();
                }

                using (var client = new RedisClient(new RedisConnection(RedisHost, RedisPort, RedisPassword), ClientQueue, ServerQueue))
                {
                    var clientFactory = new ServiceClientFactory(client);

                    var serviceClient = clientFactory.CreateServiceClient <ITestService2>();

                    var tasks = Enumerable.Range(0, nMsgs)
                                //.Select(i => serviceClient.SumAsync(5, 15))
                                .Select(i => serviceClient.ListPersonsAsync(7))
                                .ToArray();

                    await Task.WhenAll(tasks);

                    Assert.True(tasks.All(t => t.Result.Count() == 7));
                }
            }
            finally
            {
                foreach (var server in servers)
                {
                    server.Dispose();
                }
            }
        }
        public async void TestSendAndReceiveExceptions()
        {
            var resolver = new DependencyResolver();

            using (var server = new RedisServer(new RedisConnection(RedisHost, RedisPort, RedisPassword), ServerQueue, new ServiceFactory(resolver)))
            {
                server.Listen();

                using (var client = new RedisClient(new RedisConnection(RedisHost, RedisPort, RedisPassword), ClientQueue, ServerQueue))
                {
                    var clientFactory = new ServiceClientFactory(client);

                    var serviceClient = clientFactory.CreateServiceClient <ITestService>();

                    //Synchronous
                    var err = Assert.Catch(async() => await serviceClient.FailAsync());
                    Assert.IsNotNull(err);
                    Assert.IsNotInstanceOf <AggregateException>(err);

                    //Asynchronous task based
                    err = Assert.Catch(() => serviceClient.Fail());
                    Assert.IsNotNull(err);
                    Assert.IsNotInstanceOf <AggregateException>(err);

                    //Asynchronous IAsyncResult based , awaiting with Task
                    err = Assert.Catch(async() => await Task.Factory.FromAsync(serviceClient.BeginFail, serviceClient.EndFail, null));
                    Assert.IsNotNull(err);
                    Assert.IsNotInstanceOf <AggregateException>(err);

                    //Timeout exceptions
                    var factoryWithTimeout       = new ServiceClientFactory(client);
                    var serviceClientWithTimeout = factoryWithTimeout.CreateServiceClient <ITestService>(50); //50ms

                    Assert.Throws <TimeoutException>(async() => await serviceClientWithTimeout.ReplyAfter(1000));
                }
            }
        }
        //[TestCase(5, 1000000)]
        public async void TestLoadBalancing(int nServers, int nMsgs)
        {
            var resolver = new DependencyResolver();

            var servers = Enumerable.Range(0, nServers)
                                    .Select(i => new RedisServer(new RedisConnection(RedisHost, RedisPort, RedisPassword), ServerQueue, new ServiceFactory(resolver)))
                                    .ToArray();

            try
            {
                foreach (var server in servers) server.Listen();

                using (var client = new RedisClient(new RedisConnection(RedisHost, RedisPort, RedisPassword), ClientQueue, ServerQueue))
                {
                    var clientFactory = new ServiceClientFactory(client);

                    var serviceClient = clientFactory.CreateServiceClient<ITestService2>();

                    var tasks = Enumerable.Range(0, nMsgs)
                        //.Select(i => serviceClient.SumAsync(5, 15))
                                          .Select(i => serviceClient.ListPersonsAsync(7))
                                          .ToArray();

                    await Task.WhenAll(tasks);

                    Assert.True(tasks.All(t => t.Result.Count() == 7));

                }

            }
            finally
            {
                foreach (var server in servers) server.Dispose();
            }

        }
        public async void TestSendAndReceiveExceptions()
        {
            var resolver = new DependencyResolver();

            using (var server = new RedisServer(new RedisConnection(RedisHost, RedisPort, RedisPassword), ServerQueue, new ServiceFactory(resolver)))
            {
                server.Listen();

                using (var client = new RedisClient(new RedisConnection(RedisHost, RedisPort, RedisPassword), ClientQueue, ServerQueue))
                {
                    var clientFactory = new ServiceClientFactory(client);

                    var serviceClient = clientFactory.CreateServiceClient<ITestService>();

                    //Synchronous
                    var err = Assert.Catch(async () => await serviceClient.FailAsync());
                    Assert.IsNotNull(err);
                    Assert.IsNotInstanceOf<AggregateException>(err);

                    //Asynchronous task based
                    err = Assert.Catch(() => serviceClient.Fail());
                    Assert.IsNotNull(err);
                    Assert.IsNotInstanceOf<AggregateException>(err);

                    //Asynchronous IAsyncResult based , awaiting with Task
                    err = Assert.Catch(async () => await Task.Factory.FromAsync(serviceClient.BeginFail, serviceClient.EndFail, null));
                    Assert.IsNotNull(err);
                    Assert.IsNotInstanceOf<AggregateException>(err);

                    //Timeout exceptions
                    var factoryWithTimeout = new ServiceClientFactory(client);
                    var serviceClientWithTimeout = factoryWithTimeout.CreateServiceClient<ITestService>(50); //50ms

                    Assert.Throws<TimeoutException>(async () => await serviceClientWithTimeout.ReplyAfter(1000));
                }
            }
        }
        //[TestCase(5, 1000000)]
        public async void TestLoadBalancingWithPoll(int nServers, int nMsgs)
        {
            var resolver = new DependencyResolver();

            using (var broker = new ZmqPollBroker(this.zmqContext, ClientInboundAddress, ServerInboundAddress))
            {
                broker.Listen();

                var servers = Enumerable.Range(0, nServers)
                                        .Select(i => new ZmqPollServer(this.zmqContext, ServerInboundAddress, new ServiceFactory(resolver)))
                                        .ToArray();

                try
                {
                    foreach (var server in servers) server.Listen();

                    using (var client = new ZmqPollClient(this.zmqContext, ClientInboundAddress))
                    {
                        var clientFactory = new ServiceClientFactory(client);

                        var serviceClient = clientFactory.CreateServiceClient<ITestService2>();

                        var tasks = Enumerable.Range(0, nMsgs)
                            //.Select(i => serviceClient.SumAsync(5, 15))
                                              .Select(i => serviceClient.ListPersonsAsync(7))
                                              .ToArray();

                        await Task.WhenAll(tasks);

                        Assert.True(tasks.All(t => t.Result.Count() == 7));
                    }

                }
                finally
                {
                    foreach (var server in servers) server.Dispose();
                }

            }
        }
Example #25
0
        public void CanHandleTimeouts()
        {
            var clientMock = new Mock<IClient>();
            this.SetupClient(clientMock, 1000); //takes 100ms to reply

            var factory = new ServiceClientFactory(clientMock.Object);
            var serviceClient = factory.CreateServiceClient<ITestService>(50); //50ms timeout

            Assert.Throws<TimeoutException>(() => serviceClient.Sum(10, 5));
        }