title: How to startup and use WCF service in another project
body: <p>I created a WCF Service Application project in VS 2012.  Implmenented the service.</p>
  
  <p>here is what it looks like:</p>
  
  <p><img src="https://i.stack.imgur.com/cv15O.jpg" alt="enter image description here"></p>
  
  <p>Now I have a fundamental issue to deal with.  I created a new Test project to create more TDD and also some TAD tests.  The TAD (Tests after Implementation) tests will test the service implementation while my TDD test will test reliant on mocking my WCF Servcie Interface.</p>
  
  <p>But now going back to my TAD tests which need to test using an implementation of the service.  I take that is I'm adding a service reference and using the clientProxy in my unit tests for TAD.</p>
  
  <p>So I add a service reference to a new C# Project.  I then continue to create some tests such as:</p>
  
  <pre><code>[TestMethod]
  public void Get_CalledViaClientProxy_ReturnsNonNullList()
  {
      var serviceClient = new CarsClient();
  
      // Act
      Cars[] events = serviceClient.Get();
  
      // Assert
      Assert.IsNotNull(events);
  }
  </code></pre>
  
  <p>When I run this it fails because the actual service is not running.  So what I've done is go back to the actual Service WCF project, right-click the service (.svc) and choose to open it in the browser which will also start the service under IIS Express.  Then my tests run fine.</p>
  
  <p>So from that, how do I make this more automated.  If another dev downloads this code, those tests should run and the service should somehow be started.  I tried to set my service project as the startup project but all that does is opens the browser to show me the file system for that project.</p>
  
  <p>How do people run the service for testing other than in IIS? and make it so it just works for devs?  If I can't get my service to run simply but pressing F5 somehow and still able to go back into my tests project to try and run unit tests then this is pointless.</p>
  
  <p><strong>When I simply try to set my "WCF Service Application" project to be the startup project</strong>, instead of just starting the service and sitting there with a console window, it opens a web page for the service.  Do I have the wrong WCF project type?  I noticed that I have a web tab because I've got a "Serviced Application" project, should I be using something else if I want to simply start up my project in VS and continue coding in other projects that utilize this running service?</p>
  
  <p>At a previous company I was at, we all put a "-d" in the WCF service project which when you ran the project it would start the service and a console window would run and just sit there, then you knew the service was running while you continued on writing TAD unit tests against it</p>
  
  <p>e.g.:</p>
  
  <p><img src="https://i.stack.imgur.com/c6EHQ.jpg" alt="enter image description here"></p>
  
  <p>however again, my WCF project is a "WCF Application Service" so I don't have that exact debug tab in mine so not sure what to do and then how we were able to have this format of tabs in the WCF service at other places I've been.  Maybe it's just a plain C# project, not a WCF project where we were putting the -d but then how was it starting the WCF service if that was the case?  Not sure if it was a plain vanilla C# project that we put that -d in but I sure do not have this same tab format in my WCF Service Application project.</p>
  
  <p><strong>Update #2</strong></p>
  
  <p>Ok I just to see the diff, added a "<strong>WCF Service Library</strong>" project along side my "<strong>WCF Service Application</strong>" project.  The tab now has that debug and now when I launch it it does start the service and the test client comes up because the VS template automatically has /client:"WcfTestClient.exe" in for the command line properties of the debug tab in the project properties.</p>
  
  <p>Since this service is going to serve as a service API that will be used cross applications, maybe I shouldn't be using a "WCF Service Application" and should be using a "WCF Service Library" type of WCF project template.</p>