-
-
Save tugberkugurlu/1993661 to your computer and use it in GitHub Desktop.
Conneg with quality
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
[TestMethod] | |
public void ConnegTest() | |
{ | |
var selector = new FormatterSelector(); | |
var response = new HttpResponseMessage(); | |
response.RequestMessage = new HttpRequestMessage(); | |
var headers = response.RequestMessage.Headers; | |
headers.Accept.Add(new MediaTypeWithQualityHeaderValue("text/plain")); | |
headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json",0.8)); | |
headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml")); | |
headers.Accept.Add(new MediaTypeWithQualityHeaderValue("*/*")); | |
var context = new FormatterContext(response, false); | |
var mediaType = new MediaTypeHeaderValue("text/plain"); | |
selector.SelectWriteFormatter(typeof (String), context,new MediaTypeFormatterCollection(),out mediaType); | |
Assert.AreEqual("application/xml",mediaType.MediaType); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment