OpenRasta testing wierdness
I was having trouble today with some OpenRasta tests using the InMemoryHost. The tests passed when run in isolation (i.e. together but as their own unit), but when run in the context of the entire test assembly the tests failed with this exception being thrown:
TestFixture failed: System.TypeInitializationException : The type initializer for 'OpenRasta.Hosting.HostManager' threw an exception.
----> OpenRasta.DI.DependencyResolutionException : No type registered for ILogger
at OpenRasta.Hosting.HostManager.RegisterHost(IHost host)
at OpenRasta.Hosting.InMemory.InMemoryHost..ctor(IConfigurationSource configuration) in c:\src\openrasta-stable\src\openrasta-core\src\OpenRasta\Hosting\InMemory\InMemoryHost.cs:line 19
The nature of the error made me suspect a static type somewhere. I cracked open the source for HostManager (via GitHub) and tracked it down to the DependencyManager. So for anyone else suffering this issue, here’s how to solve it. Calling DependencyManager.SetResolver() is the cause, so if you have a test that does this then you need to make sure you call Dependencymanager.UnsetResolver() afterwards. Simple.
I should admit that I’ve only myself to blame for this, because it’s written right here in the documentation. Schoolboy error, right?
Anyway. Now I’ve got 46 tests passed, 0 failed. Lovely.
Tweets
- Confession: This past year, I forgot that I'm a geek. I love technology. I am obsessed with software. And now it's time to be myself again!
- @Jermolene I can just imagine you outside with your laptop in a cardboard box. That is so completely you. Awesome.
- What's the best device for writing code outdoors in the sunshine? It's a beautiful day outside and I'm stuck indoors:(
- RT @randompunter: 10 Check Amazon.co.uk for cheap touchpad. 20 GOTO 10
- @IJohnson_TNF typical example of a beautiful Ruby blog - http://t.co/6lHzwX2 show me a .NET blog like that!
- @IJohnson_TNF I think the ruby people are just more shiny
- Blogs about Ruby are always so much prettier than blogs about .NET.
- @Oura_In_Flames It's not all that amazing, and very short!
- @Oura_In_Flames you played the Sonic Generations demo yet? ;)
- @Oura_In_Flames cheers for the birthday wishes, I've been too busy at work to even think about it...
- Reading Programming in Scala, and loving it!
- Learning Scala this weekend... Quite exciting!
- @serialseb okay, on Thursday ;)
- @Oura_In_Flames lol thanks
- After two weeks of dev, finally deployed my OpenRasta app on IIS. Feeling so pleased with myself!
- Arrived at work for 8am. First time that's happened in years!
- Last one in the office - again. #deadlines
- Finishing the evening with a book in bed!
- @Oura_In_Flames Then I must have done something terribly bad as I just got drenched
- Dear Mother Nature, please check your wall calendar is on the correct page. It's June, not January. Yes, June. #wet




