public GetPerRequestFormatterInstance ( Type type, |
||
type | Type | |
request | ||
mediaType | ||
Résultat | System.Net.Http.Formatting.MediaTypeFormatter |
public void GetPerRequestFormatterInstance_Returns_Tracing_MediaTypeFormatter() { // Arrange Mock <MediaTypeFormatter> mockReturnFormatter = new Mock <MediaTypeFormatter>() { CallBase = true }; Mock <MediaTypeFormatter> mockFormatter = new Mock <MediaTypeFormatter>() { CallBase = true }; mockFormatter.Setup( f => f.GetPerRequestFormatterInstance(It.IsAny <Type>(), It.IsAny <HttpRequestMessage>(), It.IsAny <MediaTypeHeaderValue>())).Returns(mockReturnFormatter.Object); TestTraceWriter traceWriter = new TestTraceWriter(); HttpRequestMessage request = new HttpRequestMessage(); MediaTypeFormatterTracer tracer = new MediaTypeFormatterTracer(mockFormatter.Object, traceWriter, request); // Act MediaTypeFormatter actualFormatter = tracer.GetPerRequestFormatterInstance(typeof(string), request, new MediaTypeHeaderValue("application/json")); // Assert Assert.IsAssignableFrom <IFormatterTracer>(actualFormatter); }
public override MediaTypeFormatter GetPerRequestFormatterInstance( Type type, HttpRequestMessage request, MediaTypeHeaderValue mediaType ) { return(_innerTracer.GetPerRequestFormatterInstance(type, request, mediaType)); }
public void GetPerRequestFormatterInstance_Returns_Tracing_MediaTypeFormatter() { // Arrange Mock<MediaTypeFormatter> mockReturnFormatter = new Mock<MediaTypeFormatter>() { CallBase = true }; Mock<MediaTypeFormatter> mockFormatter = new Mock<MediaTypeFormatter>() { CallBase = true }; mockFormatter.Setup( f => f.GetPerRequestFormatterInstance(It.IsAny<Type>(), It.IsAny<HttpRequestMessage>(), It.IsAny<MediaTypeHeaderValue>())).Returns(mockReturnFormatter.Object); TestTraceWriter traceWriter = new TestTraceWriter(); HttpRequestMessage request = new HttpRequestMessage(); MediaTypeFormatterTracer tracer = new MediaTypeFormatterTracer(mockFormatter.Object, traceWriter, request); // Act MediaTypeFormatter actualFormatter = tracer.GetPerRequestFormatterInstance(typeof(string), request, new MediaTypeHeaderValue("application/json")); // Assert Assert.IsAssignableFrom<IFormatterTracer>(actualFormatter); }