seldary
seldary

Reputation: 6256

"Oh noes!" exception in Nancy testing

The inner exception:

{"Unable to locate view 'home'\r\nCurrently available view engine extensions: cshtml,vbhtml,sshtml,html,htm\r\nLocations inspected: ,,,,,,,,views/Store/home-he-   IL,views/Store/home,Store/home-he-IL,Store/home,views/home-he-IL,views/home,home-he-IL,home\r\nRoot path: "}

The test code:

[TestFixture]
public class Class1
{
    [Test]
    public void Spike()
    {
        // Given
        var foo = typeof (RazorViewEngine);
        var bar = typeof (SuperSimpleViewEngine);
        var bootstrapper = new Bootstrapper();
        var browser = new Browser(bootstrapper);

        // When
        var result = browser.Get("/mytest", with =>
        {
            with.HttpRequest();
        });

        // Then
        Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
    }
}

The Module looks like this:

public class YonatanModule : NancyModule
{
    public YonatanModule()
    {
        Get["/mytest"] = o =>
            {
                return View["home"];
            };
    }        
}

I've tried to add a reference to Nancy.ViewEngines.Razor, according to this and this.
I'm using Nancy 0.16.1, with Razor (Although I'm trying this first test with a clean html page).
Also, I'm using Azure, but in this case I do not run the emulator or anything.

Upvotes: 5

Views: 1232

Answers (1)

seldary
seldary

Reputation: 6256

Solved by marking the view "Copy Always" in "Copy to Output Directory".
Not sure why it works in the web project but not via the Browser in the test project.

Upvotes: 3

Related Questions