Пример #1
0
        public void ShouldRespectClientPrioritization()
        {
            var request = new HttpRequest("GET", echoUri).WithAcceptTypes("application/xml", "text/plain");
            var response = request.GetResponse();

            Assert.That(response.ContentType, Text.StartsWith("application/xml"));
        }
Пример #2
0
        public void ShouldSendPlainTextIfClientSendsUnacceptableAcceptTypes()
        {
            var request = new HttpRequest("GET", echoUri).WithAcceptTypes("audio/*", "text/csv");
            var response = request.GetResponse();

            Assert.That(response.ContentType, Text.StartsWith("text/plain"));
        }
Пример #3
0
        public void ShouldSendXmlIfClientAcceptsXmlButNotPlainText()
        {
            var request = new HttpRequest("GET", echoUri).WithAcceptTypes("text/html", "application/xml");
            var response = request.GetResponse();

            Assert.That(response.ContentType, Text.StartsWith("application/xml"));
            Assert.That(response.Body, Is.EqualTo("<echo>hello</echo>"));
        }
Пример #4
0
        public void ShouldSendPlainTextIfNoAcceptTypeGiven()
        {
            var request = new HttpRequest("GET", echoUri).WithAcceptTypes("");
            var response = request.GetResponse();

            Assert.That(response.ContentType, Text.StartsWith("text/plain"));
            Assert.That(response.Body, Is.EqualTo("hello"));
        }
Пример #5
0
        public void PassingFormatOnUrlShouldBypassContentNegotiation()
        {
            var request = new HttpRequest("GET", echoUri + ".xml").WithAcceptTypes("text/plain");
            var response = request.GetResponse();

            Assert.That(response.Body, Is.EqualTo("<echo>hello</echo>"));
            Assert.That(response.ContentType, Text.StartsWith("application/xml"));
        }