Reputation: 5664
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.
Upvotes: 4
Views: 263
Reputation: 22310
Most probably the robots.txt file is not copied to the build output of your test assembly. Make sure it is there.
Upvotes: 2