public void OnPremiseRequestSender_CreateClient()
        {
            MockDispatcher dispatcher = new MockDispatcher();

            OnPremiseRequestSender sender = new OnPremiseRequestSender(this.address, this.binding, this.serviceOperationTimeout, dispatcher, this.serviceInitializationTimeout, this.initEndpointNotFoundWaitPeriod);

            sender.CreateClientAsync(false, 0);

            ServiceClient client = Utility.GetServiceClient(sender);

            Assert.AreNotEqual(client, null, "ServiceClient.Client should not be null.");

            Assert.AreEqual(client.Endpoint.Address.ToString(), addressString, "ServiceClient.Client epr address should be the same as expected one.");
        }
        public void OnPremiseRequestSender_ReleaseClient()
        {
            MockDispatcher dispatcher = new MockDispatcher();

            OnPremiseRequestSender sender = new OnPremiseRequestSender(this.address, this.binding, this.serviceOperationTimeout, dispatcher, this.serviceInitializationTimeout, this.initEndpointNotFoundWaitPeriod);

            sender.CreateClientAsync(false, 0);

            sender.ReleaseClient();

            // client is closed by async call, so wait for a while here.
            Thread.Sleep(1000);

            ServiceClient client = Utility.GetServiceClient(sender);

            Assert.AreNotEqual(client.State, CommunicationState.Created, "ServiceClient.Client should not be at created state.");
        }
        public void OnPremiseRequestSender_StartClient()
        {
            MockDispatcher dispatcher = new MockDispatcher();

            OnPremiseRequestSender sender = new OnPremiseRequestSender(this.address, this.binding, this.serviceOperationTimeout, dispatcher, this.serviceInitializationTimeout, this.initEndpointNotFoundWaitPeriod);

            sender.CreateClientAsync(false, 0);

            bool clientStart = false;

            GetNextRequestState state =
                new GetNextRequestState(
                    (index) =>
            {
                clientStart = true;
            },
                    0);

            sender.StartClient(state);

            Assert.AreEqual(clientStart, true, "The local variable clientStart should be set when start client.");
        }