public void InvalidateSoapClientChannelFactoryTest() { ServiceCollection ServiceCollection = new ServiceCollection(); int ChannelFactoryInstancesCreated = 0; ISoapClientFactory?SoapClientFactory = null; ServiceCollection .AddSoapClient <ITestProxy, TestProxy>((serviceProvider, soapClientFactory) => { SoapClientFactory = soapClientFactory; ChannelFactoryInstancesCreated++; return(new ChannelFactory <ITestProxy>(new BasicHttpBinding(), new EndpointAddress("http://localhost:9999/"))); }); ServiceProvider ServiceProvider = ServiceCollection.BuildServiceProvider(); ITestProxy TestProxy = ServiceProvider.GetRequiredService <ITestProxy>(); Assert.IsNotNull(TestProxy); TestProxy = ServiceProvider.GetRequiredService <ITestProxy>(); Assert.IsNotNull(TestProxy); Assert.IsNotNull(SoapClientFactory); SoapClientFactory.Invalidate <ITestProxy>(); TestProxy = ServiceProvider.GetRequiredService <ITestProxy>(); Assert.IsNotNull(TestProxy); Assert.AreEqual(2, ChannelFactoryInstancesCreated); }
public void EndpointBehaviorRegisteredServiceTest() { ServiceCollection ServiceCollection = new ServiceCollection(); ChannelFactory <ITestProxy>?Factory = null; ServiceCollection .AddSoapClient <ITestProxy, TestProxy>((serviceProvider, soapClientFactory) => { Factory = new ChannelFactory <ITestProxy>(new BasicHttpBinding(), new EndpointAddress("http://localhost:9999/")); return(Factory); }) .AddEndpointBehavior <CustomEndpointBehavior>(); ServiceProvider ServiceProvider = ServiceCollection.BuildServiceProvider(); ITestProxy TestProxy = ServiceProvider.GetRequiredService <ITestProxy>(); Assert.IsNotNull(Factory); CustomEndpointBehavior?CustomEndpointBehavior = Factory.Endpoint.EndpointBehaviors[typeof(CustomEndpointBehavior)] as CustomEndpointBehavior; Assert.IsNotNull(CustomEndpointBehavior); Assert.IsTrue(CustomEndpointBehavior.ClientBehaviorApplied); }