How to speed up WCF unit tests? (Creating / closing ServiceHost is slow ...)

I am already in the process of writing a test for a server that is implemented in WCF because the messages are complex and callbacks are made for clients that I want to include in WCF tests.

(You can call these “fit” tests or “integration tests” not modular, the code on both sides of the WCF will contain more unit test details that do not use WCF.)

As my server keeps state, and I want to check that all channels are disabled without errors, I have code like:

    [SetUp]
    public void SetUp()
    {
        //TODO find a fee port rathern then hard coding
        endPointAddress = "net.tcp://localhost:1234";

        mockEngineManagerImp = new Mock<IEngineManagerImp>();              

        EngineManager engineManager = new EngineManager(mockEngineManagerImp.Object);

        serviceHost = new ServiceHost(engineManager);
        serviceHost.AddServiceEndpoint(
            typeof(IEngineManager), 
            new NetTcpBinding(SecurityMode.None),
            endPointAddress);

        serviceHost.Open();      
    }

    [TearDown]
    public void TearDown()
    {
        serviceHost.Close();
    }

However, my tests are very slow ....

How to speed up the creation and destruction of my ServiceHost?

+5
source share
4

- ,

, , , TCP .

10 .

+3

, WCF. , .

. , , WCF ( DataContractSerializer). WCF .

, .


: , .

  • ?
  • ? (, )
  • ? ?
  • ? (, , , , , )
+5

, , WCF :

(, [OperationBehavior (TransactionAutoCompete = true, TransactionScopeRequired = true)]), , WCF. , , , WCF.

, named-pipe. , , /.

/ , , , , YMMV. .

+3

Fixture, , , [FixtureSetup] [FixtureTeardown], [SetUp] [Teardown] .

, WCF ...

+2

All Articles