public void AddSoapClientProxyTest() { ServiceCollection ServiceCollection = new ServiceCollection(); ServiceCollection .AddSoapClient <ITestProxy, TestProxy>((serviceProvider, soapClientFactory) => new ChannelFactory <ITestProxy>(new BasicHttpBinding(), new EndpointAddress("http://localhost:9999/"))); ServiceProvider ServiceProvider = ServiceCollection.BuildServiceProvider(); ITestProxy TestProxy; using (IServiceScope Scope = ServiceProvider.CreateScope()) { TestProxy = Scope.ServiceProvider.GetRequiredService <ITestProxy>(); Assert.IsNotNull(TestProxy); try { TestProxy.GetStatus(); } catch (CommunicationException) { } } Assert.AreEqual(CommunicationState.Closed, TestProxy.ChannelState); }