I have a Nancy based web project and a unit test project using MSTest referencing a web project.
I added the 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 method ConfigureConventionsin Bootstrapper.
unit test is as follows:
[TestMethod]
public void Get_Robotstxt_Should_Return_Status_OK()
{
var browser = new Browser(new Bootstrapper());
var result = browser.Get("/robots.txt");
Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
}
In reality, when deployed, this code works just fine, it's just a test that doesn't work.
source
share