Skip to content

Instantly share code, notes, and snippets.

@starteleport
Last active December 10, 2015 23:48
Show Gist options
  • Save starteleport/4511700 to your computer and use it in GitHub Desktop.
Save starteleport/4511700 to your computer and use it in GitHub Desktop.
ServiceStack tests/ServiceStack.WebHost.Endpoints.Tests/AttributeFiltersTest.cs
public class ThrowingFilterAttribute : RequestFilterAttribute
{
public override void Execute(IHttpRequest req, IHttpResponse res, object requestDto)
{
throw new ArgumentException("exception message");
}
}
[Route("/throwingattributefiltered")]
public class ThrowingAttributeFiltered : IReturn<string>
{
}
[ThrowingFilter]
public class ThrowingAttributeFilteredService : IService<ThrowingAttributeFiltered>
{
public object Execute(ThrowingAttributeFiltered request)
{
return "OK";
}
}
[Test]
public void Proper_exception_is_serialized_to_client()
{
var client = new HtmlServiceClient(ServiceClientBaseUri);
client.SetBaseUri(ServiceClientBaseUri);
try
{
client.Get(new ThrowingAttributeFiltered());
}
catch (WebServiceException e)
{
//Ensure we have stack trace present
Assert.IsTrue(e.ResponseBody.Contains("ThrowingFilterAttribute"), "No stack trace in the response (it's probably empty)");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment