I'm very new to ServiceStack. So far, I've had good fortune in getting a basic API up and working (the Northwind example was particularly helpful for me). However, I'm stumbling when trying to build unit and integration tests.
I've found a recent gist from another ServiceStack user who illustrated a few (possibly incorrect) examples of unit and integration tests, but I cannot get those working.
Here is the reference I've been using: https://github.com/ServiceStack/ServiceStack/issues/435
Here is my attempt at a basic unit test, using mostly borrowed code from the other user's gist: https://gist.github.com/anonymous/4957788
When I attempt to run the test case in HelloWorldTest, a System.NotImplementedException is thrown, stating "Unable to resolve service 'HelloWorldName'".
This is confusing to me, as I'm passing it a request DTO, not a service, which seems to agree with the ExecuteService() method I'm calling. But the exception suggests that ServiceStack is treating my DTO as a service.
Could somebody possibly send me to a good, canonical example of how to correctly write unit and integration tests for ServiceStack? I should mention that I'm also new to .NET development in general, so perhaps my ignorance is shining through.
Many thanks.
Look at the testing docs and this earlier question and answer for a simple example on how to create a Unit and Integration test.
Also most of the tests in ServiceStack.WebHost.Endpoints.Tests are stand-alone integration tests that just use a self-hosted HttpListener AppHost. Some examples:
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