Last active
December 10, 2015 23:48
-
-
Save starteleport/4511700 to your computer and use it in GitHub Desktop.
ServiceStack
tests/ServiceStack.WebHost.Endpoints.Tests/AttributeFiltersTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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