示例#1
0
        public void ProcessResults_WithImplicitEqualPriorityXmlAndJsonAcceptHeader_ReturnsJsonResult()
        {
            var request = buildFakeRequestWithAccept("application/xml,application/json");
            var response = new FakeResponseContext();

            var result = new JsonOrXmlResult(new CustomType { Data = "data", Number = 50 });

            result.ProcessResult(request, response);

            Assert.That(response.ContentType, Is.EqualTo("application/json"));
        }
示例#2
0
        public void ProcessResults_WithJsonFormatExtensionOverride_ReturnsJsonResult()
        {
            var request = buildFakeRequestWithAcceptAndRouteValues("application/xml;q=0.7,application/json;q=0.1", new RouteValueDictionary { { "format", "json" } });
            var response = new FakeResponseContext();

            var result = new JsonOrXmlResult(new CustomType { Data = "data", Number = 50 });

            result.ProcessResult(request, response);

            Assert.That(response.ContentType, Is.EqualTo("application/json"));
        }
示例#3
0
        public void ProcessResults_WithHigherPriorityXmlAcceptHeader_ReturnsJsonResult()
        {
            var request = buildFakeRequestWithAccept("application/xml;q=0.7,application/json;q=0.6");
            var response = new FakeResponseContext();

            var result = new JsonOrXmlResult(new CustomType { Data = "data", Number = 50 });

            Assert.That((result.Data as CustomType).Data, Is.EqualTo("data"));
            Assert.That((result.Data as CustomType).Number, Is.EqualTo(50));

            result.ProcessResult(request, response);

            Assert.That(response.ContentType, Is.EqualTo("application/xml"));
        }