public static void ClientBaseCloseMethodClosesCorrectly() { // *** SETUP *** \\ BasicHttpBinding binding = new BasicHttpBinding(); MyClientBase client = new MyClientBase(binding, new EndpointAddress("http://myendpoint")); // *** VALIDATE *** \\ Assert.Equal(CommunicationState.Created, client.State); client.Open(); Assert.Equal(CommunicationState.Opened, client.State); client.Close(); Assert.Equal(CommunicationState.Closed, client.State); }
public static void ClientBaseChannelFactoryDefaultCachingBindingEndpointAddress() { Assert.Equal(CacheSetting.Default, MyClientBase.CacheSetting); BasicHttpBinding binding = new BasicHttpBinding(); EndpointAddress endpointAddress = new EndpointAddress("http://myendpoint"); MyClientBase client1 = new MyClientBase(binding, endpointAddress); client1.Open(); MyClientBase client2 = new MyClientBase(binding, endpointAddress); client2.Open(); Assert.NotEqual(client1.ChannelFactory, client2.ChannelFactory); client1.Close(); client2.Close(); // Validate setting to same value doesn't throw MyClientBase.CacheSetting = CacheSetting.Default; // Validate instantiated caching throws when changing setting Assert.Throws <InvalidOperationException>(() => MyClientBase.CacheSetting = CacheSetting.AlwaysOn); }