[C#] Ensuring Project A starts when Project B needs it...

Caporegime
Joined
18 Oct 2002
Posts
29,493
Location
Back in East London
Howdy.. I've got two projects, one with my WCF service (Project A), another with my "test" client (Project B) that communicates with said service. Both are in the same solution.

As we are using automated integration/testing.. it'd be nice to have a simple line in our tests to "start" Project A when we are using the tests in Project B.

Setting Project A as a dependency of Project B doesn't do the trick.

Something like..
Code:
Assembly.StartProject("Project A");
or whatever :)

Anyone know of something?
 
Last edited:
See, I guess I wasn't specific enough.. Project B never actually "starts" .. only the tests are run within it. And to complicate things a little further, we aren't using MSTest, we are using NUnit. :)
 
It is an integration test :)

I don't know what to put into my SetUp to start the service, hence this thread I guess :)
 
I'm not sure that solves the problem, perhaps I am misunderstanding. Project A is nothing but the WCF service, and Project B is nothing but tests with a Service Reference to what is effectively Project A.

a quick example of what happens:

A snippet from Service project:
Code:
[ServiceContract]
interface IWebService
{
  [OperationContract]
  public string DoSomething(string anArg);
}

public class WebService : IWebService
{
  public string DoSomething(string anArg)
  {
    if (anArg == "foo") return "bar";
    return null;
  }
}
Snippet from Tests project (with a service reference to Service project):
Code:
[TestFixture]
public class TestService
{
  public WebService Service;

  [SetUp]
  public void SetUp
  {
    Service = new WebServiceClient();
  }

  [Test]
  public void TestDoSomething()
  {
    var result = Service.DoSomething("foo");
    Assert.That(result, Is.EqualTo("bar"));
  }
}
But the test times out because the Service project has not started.
 
So other than instantiating a service host (and keep it in 'Project C' as you rightly say) there isn't simply a way to just start the project? :) I was hoping there was a way to do it similar to how the IDE starts the project when I update my service reference in project B, project A automatically starts (as it is updating a design time localhost URI)
 
Back
Top Bottom