Ejemplo n.º 1
0
        public void CloseOpenedWCFClientBaseOnReleaseOnlineProxy()
        {
            using (ServiceHost serviceHost = new ServiceHost(typeof(MockForReleaseService)))
            {
                serviceHost.Open();
                WCFProxyFactory <IMockForReleaseService> factory = new WCFProxyFactory <IMockForReleaseService>();
                MockClientForRelease client = new MockClientForRelease();
                client.Foo();
                factory.ReleaseOnlineProxy(client);

                Assert.AreEqual(CommunicationState.Closed, client.State);
            }
        }
Ejemplo n.º 2
0
        public void WhenServiceHostIsDownProxyFactoryShouldLeaveTheClientInClosedState()
        {
            WCFProxyFactory <IMockForReleaseService> factory = new WCFProxyFactory <IMockForReleaseService>();
            MockClientForRelease client = new MockClientForRelease();

            try
            {
                client.Foo();
                Assert.Fail("Should have thrown exception");
            }
            catch (CommunicationException)
            {
                Assert.AreEqual(CommunicationState.Faulted, client.State);
                factory.ReleaseOnlineProxy(client);
                Assert.AreEqual(CommunicationState.Closed, client.State);
            }
        }
Ejemplo n.º 3
0
        public void WhenServiceThrowsProxyFactoryShouldLeaveTheClientInClosedState()
        {
            using (ServiceHost serviceHost = new ServiceHost(typeof(MockForReleaseService)))
            {
                serviceHost.Open();

                WCFProxyFactory <IMockForReleaseService> factory = new WCFProxyFactory <IMockForReleaseService>();
                MockClientForRelease client = new MockClientForRelease();
                try
                {
                    client.FooThrow();
                    Assert.Fail("Should have thrown exception");
                }
                catch (Exception)
                {
                    Assert.AreEqual(CommunicationState.Faulted, client.State);
                    factory.ReleaseOnlineProxy(client);
                    Assert.AreEqual(CommunicationState.Closed, client.State);
                }
            }
        }