Question

I have a Nancy based web project and a unit test project using MSTest referencing the web project.

I have added a robots.txt file to the Content folder in the web project. I added a static content path to it using nancyConventions.StaticContentsConventions.AddFile("/robots.txt", "/Content/robots.txt"); in the ConfigureConventions method in Bootstrapper.

The unit test looks like this:

[TestMethod]
public void Get_Robotstxt_Should_Return_Status_OK()
{
    // Given
    var browser = new Browser(new Bootstrapper());

    // When
    var result = browser.Get("/robots.txt");

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

The code actually works fine when deployed, it is just the test that doesn't work.

Was it helpful?

Solution

Most probably the robots.txt file is not copied to the build output of your test assembly. Make sure it is there.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top