Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"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.

like image 705
seldary Avatar asked Oct 22 '22 09:10

seldary


1 Answers

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.

like image 111
seldary Avatar answered Oct 27 '22 11:10

seldary