Nancy.Testing - testing (razor) views

Posted by Marcus Hammarberg on February 4, 2013
I'm in the middle of writing a blog post series on Nancy.Testing and this bit me a bit (sorry, couldn't resist myself).

I have written a lot about how to test web-responses and all the great stuff that comes with it, but totally forgot about view. I assumed that it "just worked". And it does but... well read on. It's really simple.

Keeping the story short - let's cut to the code:

There's some really important settings to make here. If you don't you'll end up with an (as always in Nancy btw) excellent error message, something like this:
Nancy.ViewEngines.ViewNotFoundException: Unable to locate view 'FariyTaleFigure'
Currently available view engine extensions: sshtml,html,htm,cshtml,vbhtml
Locations inspected: ,,,,,,,,views/SimpleDataModuleWithView/FariyTaleFigure-sv-SE,views/SimpleDataModuleWithView/FariyTaleFigure,SimpleDataModuleWithView/FariyTaleFigure-sv-SE,SimpleDataModuleWithView/FariyTaleFigure,views/FariyTaleFigure-sv-SE,views/FariyTaleFigure,FariyTaleFigure-sv-SE,FariyTaleFigure
Root path: C:\Dev\DiscoveringNancyThroughTests\DiscoverNancy.Tests\NancyAndSimpleData.Tests\bin\Debug
Oh yeah - the two settings you need to do:
After that it'll "just work".

You can read more about the awesome testing capabilities of Nancy here.
My code can be found here.

Published by Marcus Hammarberg on Last updated