title: How to set up the end points in unit test for the self hosted wcf service?
body: <p>I've followed the advice on this forum and create a unit test to test for the connectivity for my self hosted wcf. It is that to create a service host in my test (self-hosted) and load my service. After that, I can set up my end points  and connect the client to the server. However, that approach would work with simple HTTP and WSHTTP while mine is NetTcp. How would I set up the end points for the NetTcp ?This is what I've been working so far:</p>
  
  <pre><code> [TestClass]
      public class UnitTest1 :ISimSession
      {
          [TestMethod]
          public void TestMethod1()
          {
              ServiceHost host = null;
              try
              {
                  var baseAddress = new Uri("http://localhost:8732/Design_Time_Addresses/NextGenService/SimSession/");
                  host = new ServiceHost(typeof(SimSession), baseAddress);
                  NetTcpBinding binding = new NetTcpBinding();
                  var address = new EndpointAddress("http://localhost:8732/Design_Time_Addresses/NextGenService/SimSession/");
  
                  var endpoint = host.AddServiceEndpoint(typeof(SimSession), binding, address.Uri);
                  var smb = new ServiceMetadataBehavior { HttpGetEnabled = true };
                  host.Description.Behaviors.Add(smb);
  
                  using(var client = ???? )
                  {
                      endpoint.Name = client.Endpoint.Name;
                      host.Open();
                  }
  
                  host.Close(); 
  
  
  
              }
              catch (Exception e)
              {
                  //...tests
  
              }
              finally
              {
                  if(host != null)
                  {
                      ((IDisposable)host).Dispose();
                  }
              }
          }
  }
  </code></pre>