I have a WebApi where I am using Windsor Castle as a IoC framework. I am using Owin library and a startup file was created to centralized the configuration of the API. Everything works as expected.
I have integration tests where I am using Owin.Testing library and the server is started using a test startup class which is inheriting the real one. The Windsor container was successfully configured for the TestServer. The integration tests are executing web requests against the running self hosted server. Everything works fine.
There are two things which are not working when using the test server:
- the ModelState of the controller is all the time valid even when I am passing an invalid json body for the POST request. When hosted with IIS it works as expected. Any idea what can be wrong with the test server?
- I am using VS test runner and the Owin TestServer is initialized in a [ClassInitialize] method. I do not want to create a new test server after each test as Windsor container initialization is quite expensive. There are tests where I need to mock some 3rd party services (by using Register method of the container and Moq). At the end of each test I want to rollback all the mocks from the container which were done in the scope of executed test. Is it possible somehow to do it? I have tried to register within a scope but does not work.
Thanks