How to make Unit Test NServiceBus.Configure.WithWeb ()?

I create a WCF service that receives requests to an external IP address and translates them into messages that are sent via NServiceBus.

One of my unit tests calls Global.Application_Start() , which configures the application and then tries to enable the web service to confirm that the container can create all the dependencies.

This works fine when I use Configure.With() on my Windows services, but the call to Configure.WithWeb() fails in this context (presumably because the β€œbin” directory does not exist?).

Is it possible to use the unit test method that calls Configure.WithWeb() , or should just use the overload for Configure.With() , which takes a directory name?

+4
source share
1 answer

I created a new launch class as follows:

 public class NonWebRunAtStartup : IRunAtStartup { public void InitializeInfrastructure(object container) { Configure.With() .StructureMapBuilder((IContainer) container) .Log4Net() .XmlSerializer() .MsmqTransport() .UnicastBus() .LoadMessageHandlers() .CreateBus() .Start(); } } 

Then, in my test, I made sure that my IOC container would use this instead of the regular web interface by adding this to my test:

 IoC.Register<IRunAtStartup, NonWebRunAtStartup>(); 

This led me to another error, which I'm still struggling with, and I will ask it as a separate question (now the NSB cannot load assemblies that are in the NServiceBus.Core.dll file, for example Antlr3.Runtime DLL).

0
source

All Articles