コード例 #1
0
        public void Can_change_serialization_options()
        {
            var mockResponse = new MockHttpResponse();

            var dto = new Poco();

            Assert.That(dto.ToJson(), Is.EqualTo("{}"));

            var httpResult = new HttpResult(dto)
            {
                ResultScope = () => JsConfig.With(includeNullValues: true)
            };

            var reponseWasAutoHandled = mockResponse.WriteToResponse(httpResult, MimeTypes.Html);

            Assert.That(reponseWasAutoHandled.Result, Is.True);

            Assert.That(mockResponse.ReadAsString(), Is.EqualTo("{\"Text\":null}").Or.EqualTo("{\"text\":null}"));
        }
コード例 #2
0
 public PocoResponse Any(Poco request)
 {
     return(new PocoResponse {
         Result = "Hello, " + (request.Text ?? "World!")
     });
 }