public void BuildChannelFactory_OnlyTransport()
        {
            var be = new DiscoveryClientBindingElement();
            var bc = new BindingContext(new CustomBinding(new HttpTransportBindingElement()), new BindingParameterCollection());

            be.BuildChannelFactory <IRequestChannel> (bc);
        }
        public void BuildChannelFactory()
        {
            var be = new DiscoveryClientBindingElement();
            var bc = new BindingContext(new CustomBinding(be, new HttpTransportBindingElement()), new BindingParameterCollection());
            var cf = be.BuildChannelFactory <IRequestChannel> (bc);

            cf.Open();
            var ch = cf.CreateChannel(DiscoveryClientBindingElement.DiscoveryEndpointAddress);

            Assert.AreEqual(DiscoveryClientBindingElement.DiscoveryEndpointAddress, ch.RemoteAddress, "#1");
        }
        public void BuildChannelFactory_CreateNonDynamicUriChannel()
        {
            var be = new DiscoveryClientBindingElement();
            var bc = new BindingContext(new CustomBinding(be, new HttpTransportBindingElement()), new BindingParameterCollection());
            var cf = be.BuildChannelFactory <IRequestChannel> (bc);

            cf.Open();
            var uri = new Uri("http://localhost:37564");

            cf.CreateChannel(new EndpointAddress(uri));
        }
        public void RequestChannelOpenFails2()
        {
            var be = new DiscoveryClientBindingElement();
            var bc = new BindingContext(new CustomBinding(be, new TcpTransportBindingElement()), new BindingParameterCollection());
            var cf = be.BuildChannelFactory <IDuplexSessionChannel> (bc);

            cf.Open();
            var ch = cf.CreateChannel(DiscoveryClientBindingElement.DiscoveryEndpointAddress);

            ch.Open(TimeSpan.FromSeconds(80));
        }
        public void RequestChannelOpenFails()
        {
            var be = new DiscoveryClientBindingElement();
            var bc = new BindingContext(new CustomBinding(be, new HttpTransportBindingElement()), new BindingParameterCollection());
            var cf = be.BuildChannelFactory <IRequestChannel> (bc);

            cf.Open();
            Assert.IsNull(cf.GetProperty <DiscoveryEndpoint> (), "#1");
            var ch = cf.CreateChannel(DiscoveryClientBindingElement.DiscoveryEndpointAddress);

            Assert.IsNull(ch.GetProperty <DiscoveryEndpoint> (), "#2");
            ch.Open(TimeSpan.FromSeconds(80));
        }
        public void RequestChannelOpenFails2()
        {
            var be = new DiscoveryClientBindingElement();

            // (The comment on RequestChannelOpenFails() applies here too.)
            be.FindCriteria.Duration = TimeSpan.FromSeconds(3);

            var bc = new BindingContext(new CustomBinding(be, new TcpTransportBindingElement()), new BindingParameterCollection());
            var cf = be.BuildChannelFactory <IDuplexSessionChannel> (bc);

            cf.Open();
            var ch = cf.CreateChannel(DiscoveryClientBindingElement.DiscoveryEndpointAddress);
            var sw = Stopwatch.StartNew();

            ch.Open(TimeSpan.FromSeconds(5));
            Assert.IsTrue(sw.Elapsed < TimeSpan.FromSeconds(15), "It is likely that FindCriteria.Duration is ignored");
        }
        public void CustomDiscoveryEndpointProvider()
        {
            var be = new DiscoveryClientBindingElement()
            {
                DiscoveryEndpointProvider = new MyDiscoveryEndpointProvider()
            };
            var bc = new BindingContext(new CustomBinding(be, new HttpTransportBindingElement()), new BindingParameterCollection());
            var cf = be.BuildChannelFactory <IRequestChannel> (bc);

            cf.Open();
            var ch = cf.CreateChannel(DiscoveryClientBindingElement.DiscoveryEndpointAddress);

            try {
                ch.Open();
                Assert.Fail("Should try to use failing endpoint provider.");
            } catch (MyException) {
            }
        }
        public void RequestChannelOpenFails()
        {
            var be = new DiscoveryClientBindingElement();

            // Note that this explicitly sets shorter timeout than open timeout for the channel.
            // If it is longer, then TimeoutException will occur instgead,
            // as the client doesn't expect longer than FindCriteria.Duration.
            be.FindCriteria.Duration = TimeSpan.FromSeconds(3);

            var bc = new BindingContext(new CustomBinding(be, new HttpTransportBindingElement()), new BindingParameterCollection());
            var cf = be.BuildChannelFactory <IRequestChannel> (bc);

            cf.Open();
            Assert.IsNull(cf.GetProperty <DiscoveryEndpoint> (), "#1");
            var ch = cf.CreateChannel(DiscoveryClientBindingElement.DiscoveryEndpointAddress);

            Assert.IsNull(ch.GetProperty <DiscoveryEndpoint> (), "#2");
            var sw = Stopwatch.StartNew();

            ch.Open(TimeSpan.FromSeconds(5));
            Assert.IsTrue(sw.Elapsed < TimeSpan.FromSeconds(15), "It is likely that FindCriteria.Duration is ignored");
        }
		public void CustomDiscoveryEndpointProvider ()
		{
			var be = new DiscoveryClientBindingElement () { DiscoveryEndpointProvider = new MyDiscoveryEndpointProvider () };
			var bc = new BindingContext (new CustomBinding (be, new HttpTransportBindingElement ()), new BindingParameterCollection ());
			var cf = be.BuildChannelFactory<IRequestChannel> (bc);
			cf.Open ();
			var ch = cf.CreateChannel (DiscoveryClientBindingElement.DiscoveryEndpointAddress);
			try {
				ch.Open ();
				Assert.Fail ("Should try to use failing endpoint provider.");
			} catch (MyException) {
			}
		}
		public void RequestChannelOpenFails2 ()
		{
			var be = new DiscoveryClientBindingElement ();
			// (The comment on RequestChannelOpenFails() applies here too.)
			be.FindCriteria.Duration = TimeSpan.FromSeconds (3);

			var bc = new BindingContext (new CustomBinding (be, new TcpTransportBindingElement ()), new BindingParameterCollection ());
			var cf = be.BuildChannelFactory<IDuplexSessionChannel> (bc);
			cf.Open ();
			var ch = cf.CreateChannel (DiscoveryClientBindingElement.DiscoveryEndpointAddress);
			DateTime start = DateTime.Now;
			ch.Open (TimeSpan.FromSeconds (5));
			Assert.IsTrue (DateTime.Now - start < TimeSpan.FromSeconds (15), "It is likely that FindCriteria.Duration is ignored");
		}
		public void RequestChannelOpenFails ()
		{
			var be = new DiscoveryClientBindingElement ();
			// Note that this explicitly sets shorter timeout than open timeout for the channel.
			// If it is longer, then TimeoutException will occur instgead,
			// as the client doesn't expect longer than FindCriteria.Duration.
			be.FindCriteria.Duration = TimeSpan.FromSeconds (3);

			var bc = new BindingContext (new CustomBinding (be, new HttpTransportBindingElement ()), new BindingParameterCollection ());
			var cf = be.BuildChannelFactory<IRequestChannel> (bc);
			cf.Open ();
			Assert.IsNull (cf.GetProperty<DiscoveryEndpoint> (), "#1");
			var ch = cf.CreateChannel (DiscoveryClientBindingElement.DiscoveryEndpointAddress);
			Assert.IsNull (ch.GetProperty<DiscoveryEndpoint> (), "#2");
			DateTime start = DateTime.Now;
			ch.Open (TimeSpan.FromSeconds (5));
			Assert.IsTrue (DateTime.Now - start < TimeSpan.FromSeconds (15), "It is likely that FindCriteria.Duration is ignored");
		}
		public void BuildChannelFactory ()
		{
			var be = new DiscoveryClientBindingElement ();
			var bc = new BindingContext (new CustomBinding (be, new HttpTransportBindingElement ()), new BindingParameterCollection ());
			var cf = be.BuildChannelFactory<IRequestChannel> (bc);
			cf.Open ();
			var ch = cf.CreateChannel (DiscoveryClientBindingElement.DiscoveryEndpointAddress);
			Assert.AreEqual (DiscoveryClientBindingElement.DiscoveryEndpointAddress, ch.RemoteAddress, "#1");
		}
		public void BuildChannelFactory_CreateNonDynamicUriChannel ()
		{
			var be = new DiscoveryClientBindingElement ();
			var bc = new BindingContext (new CustomBinding (be, new HttpTransportBindingElement ()), new BindingParameterCollection ());
			var cf = be.BuildChannelFactory<IRequestChannel> (bc);
			cf.Open ();
			var uri = new Uri ("http://localhost:37564");
			cf.CreateChannel (new EndpointAddress (uri));
		}
		public void BuildChannelFactory_OnlyTransport ()
		{
			var be = new DiscoveryClientBindingElement ();
			var bc = new BindingContext (new CustomBinding (new HttpTransportBindingElement ()), new BindingParameterCollection ());
			be.BuildChannelFactory<IRequestChannel> (bc);
		}
		public void RequestChannelOpenFails2 ()
		{
			var be = new DiscoveryClientBindingElement ();
			var bc = new BindingContext (new CustomBinding (be, new TcpTransportBindingElement ()), new BindingParameterCollection ());
			var cf = be.BuildChannelFactory<IDuplexSessionChannel> (bc);
			cf.Open ();
			var ch = cf.CreateChannel (DiscoveryClientBindingElement.DiscoveryEndpointAddress);
			ch.Open ();
		}
		public void RequestChannelOpenFails ()
		{
			var be = new DiscoveryClientBindingElement ();
			var bc = new BindingContext (new CustomBinding (be, new HttpTransportBindingElement ()), new BindingParameterCollection ());
			var cf = be.BuildChannelFactory<IRequestChannel> (bc);
			cf.Open ();
			Assert.IsNull (cf.GetProperty<DiscoveryEndpoint> (), "#1");
			var ch = cf.CreateChannel (DiscoveryClientBindingElement.DiscoveryEndpointAddress);
			Assert.IsNull (ch.GetProperty<DiscoveryEndpoint> (), "#2");
			ch.Open ();
		}