public void WebServiceProxyFactorySetsCredential()
        {
            Request request = new Request();

            request.Endpoint        = "endpoint";
            request.OnlineProxyType = typeof(MockClient);

            NetworkCredential creds = new NetworkCredential("user", "pwd");

            MockEndpointCatalog catalog  = new MockEndpointCatalog();
            MockEndpoint        endpoint = new MockEndpoint("endpoint");

            endpoint.Default            = new MockEndpointConfig(defaultURL);
            endpoint.Default.Credential = creds;
            catalog.Endpoints.Add("endpoint", endpoint);

            WCFProxyFactory <IMockService> factory = new WCFProxyFactory <IMockService>((IEndpointCatalog)catalog);

            MockClient proxy = (MockClient)factory.GetOnlineProxy(request, "Network");

            Assert.IsNotNull(proxy);

            Assert.AreEqual("user", proxy.ClientCredentials.UserName.UserName);
            Assert.AreEqual("pwd", proxy.ClientCredentials.UserName.Password);
        }
        public void FactoryCallTheSpecifiedMethod()
        {
            Request request = new Request();

            request.Endpoint        = "endpoint";
            request.MethodName      = "CalledMethod";
            request.OnlineProxyType = typeof(MockClient);

            NetworkCredential creds = new NetworkCredential("user", "pwd");

            MockEndpointCatalog catalog  = new MockEndpointCatalog();
            MockEndpoint        endpoint = new MockEndpoint("endpoint");

            endpoint.Default            = new MockEndpointConfig(defaultURL);
            endpoint.Default.Credential = creds;
            catalog.Endpoints.Add("endpoint", endpoint);

            WCFProxyFactory <IMockService> factory = new WCFProxyFactory <IMockService>((IEndpointCatalog)catalog);

            MockClient proxy = (MockClient)factory.GetOnlineProxy(request, "Network");

            Exception exception = null;

            factory.CallOnlineProxyMethod(proxy, request, ref exception);

            Assert.IsTrue(proxy.MethodCalled);
        }
        public void GetOnlineProxyUsesProxyAddressIfNoEndPointConfigured()
        {
            Request request = new Request();

            request.Endpoint        = "MissingEndpoint";
            request.MethodName      = "CalledMethod";
            request.OnlineProxyType = typeof(MockClient);
            MockEndpointCatalog            catalog = new MockEndpointCatalog();
            WCFProxyFactory <IMockService> factory = new WCFProxyFactory <IMockService>((IEndpointCatalog)catalog);

            MockClient proxy = (MockClient)factory.GetOnlineProxy(request, "Network");

            Assert.IsNotNull(proxy);
            Assert.IsNotNull(proxy.Endpoint);
            Assert.AreEqual(new EndpointAddress("http://myurl.com"), proxy.Endpoint.Address);
        }