NancyFx Unit Testing How do I pass a browser route parameter using a test browser?

I am trying to pass a route parameter (not a Query Paramter!) Through a Nancy.Testing.Browser object. I understand (now) how to send and consume query strings to / from my NancyModule:

var customerResponse = browser.Get("/customer/id", with =>
{
    with.HttpRequest();
    with.Query("{id}", alansIdGuid.ToString());
});

...

Get["/customer/{id}"] = parameters =>
{
    string idFromQuery = Request.Query.id;
    Customer customerFromId = _customerRepo.GetCustomerById(idFromQuery);
    return Response.AsJson<Customer>(customerFromId);
};

However, what I want to do is click on my route and get my route parameter as follows:

Get["/customer/{id}"] = parameters =>
{
    string id = parameters.id;
    Customer customerFromId = _customerRepo.GetCustomerById(id);
    return Response.AsJson<Customer>(customerFromId);
};  

How do I pass an Id parameter as a route parameter using Nancy.Testing.Browser?

- Without using headers, cookies or query strings?

It was a 3-hour search for an apparently simple task! The following questions dance around the problem, but do not solve it:

Send parameter to Nancy module from test

NancyFX: Routes with query string parameters always return 404 NotFound

NancyFX?

+4
1

... , .

var customerResponse = browser.Get("/customer/" + alansIdGuid.ToString(), with =>
{             
    with.HttpRequest();
});

/ URL- Nancy.Testing.Browser, .

+5

All Articles