Im looking at the source code for unit testing in ServiceStackTestHostBase.cs - and got it running with my own project. How would i go around enabling my plugins when unit testing without actually starting a listener? For examples i would like to test that my web service validates correctly, so i add the following code to Configure in TestHostBase.cs.
Plugins.Add(new ValidationFeature());
container.RegisterValidators(typeof(CustomerModelValidator).Assembly);
But when calling base.send with a Customer object which violates a validation rule no validation are done. (Note: Validation works allright when i start my webservice with a listener)
Since Plugins can mutate any part of an AppHost (i.e. Add Routes, ContentTypes, Request/Response Filters, CatchAll Handlers, etc). They're not possible to test its integration with your services without starting a HttpListener (or ASP.NET host).
Of course if your Plugin is testable, you can unit test it in isolation, separate from your services.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With