have a controller with the following method signature
public IHttpActionResult GetResults(string searchQuery, int from = 0)
Now before people start complaining why I've not included the rest of the body of the controller, I can assure you it's because it is not relevant. The next relevant bit is the exception handler:
catch (Exception ex)
{
Exceptions.Failed(ex, Request);
var resp = new HttpResponseMessage(HttpStatusCode.InternalServerError)
{
Content = new StringContent("Elasticsearch is down"),
};
throw new HttpResponseException(resp);
}
Here is my unit test:
public class when_elastic_is_down : setup_controller
{
private Because of = () => results = controller.GetResults("moxi");
private It should_not_return_500 =
() => (results as HttpResponseMessage).StatusCode.ShouldEqual(500);
}
The problem I'm having is that intellisense reports the following error on ShouldEqual:
The type arguments for method 'T Machine.Specification.ShouldExtensionMethods.ShouldEqual<T>(this, T,T)' cannot be inferred from the usage. Try specifying the arguments explicitly.Can someone explain why I'm not able to check the property of StatusCode?
(results as HttpResponseMessage).StatusCode.ShouldEqual(HttpStatusCode.InternalServerError);--
You received this message because you are subscribed to the Google Groups "machine_users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to machine_user...@googlegroups.com.
To post to this group, send email to machin...@googlegroups.com.
Visit this group at https://groups.google.com/group/machine_users.
For more options, visit https://groups.google.com/d/optout.