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); } }
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); } }
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); } } }