public void CanWriteResult_OnlyActsOnStreams(Type type) { // Arrange var formatter = new StreamOutputFormatter(); var @object = type != null?Activator.CreateInstance(type) : null; var context = new OutputFormatterWriteContext( new DefaultHttpContext(), new TestHttpResponseStreamWriterFactory().CreateWriter, type, @object); // Act var result = formatter.CanWriteResult(context); // Assert Assert.False(result); }
public void CanWriteResult_OnlyActsOnStreams(Type type) { // Arrange var formatter = new StreamOutputFormatter(); var @object = type != null ? Activator.CreateInstance(type) : null; var context = new OutputFormatterWriteContext( new DefaultHttpContext(), new TestHttpResponseStreamWriterFactory().CreateWriter, type, @object); // Act var result = formatter.CanWriteResult(context); // Assert Assert.False(result); }
public void CanWriteResult_OnlyActsOnStreams_IgnoringContentType(Type type, string contentType) { // Arrange var formatter = new StreamOutputFormatter(); var contentTypeHeader = contentType == null ? new StringSegment() : new StringSegment(contentType); var context = new OutputFormatterWriteContext( new DefaultHttpContext(), new TestHttpResponseStreamWriterFactory().CreateWriter, type, new SimplePOCO()) { ContentType = contentTypeHeader, }; // Act var canWrite = formatter.CanWriteResult(context); // Assert Assert.False(canWrite); }
public void CanWriteResult_ReturnsTrue_ForStreams(Type type, string contentType) { // Arrange var formatter = new StreamOutputFormatter(); var contentTypeHeader = new StringSegment(contentType); var context = new OutputFormatterWriteContext( new DefaultHttpContext(), new TestHttpResponseStreamWriterFactory().CreateWriter, type, new MemoryStream()) { ContentType = contentTypeHeader, }; // Act var canWrite = formatter.CanWriteResult(context); // Assert Assert.True(canWrite); }
public void CanWriteResult_OnlyActsOnStreams_IgnoringContentType(Type type, string contentType) { // Arrange var formatter = new StreamOutputFormatter(); var contentTypeHeader = contentType == null ? new StringSegment() : new StringSegment(contentType); var context = new OutputFormatterWriteContext( new DefaultHttpContext(), new TestHttpResponseStreamWriterFactory().CreateWriter, type, new SimplePOCO()) { ContentType = contentTypeHeader, }; // Act var canWrite = formatter.CanWriteResult(context); // Assert Assert.False(canWrite); }
public void CanWriteResult_ReturnsTrue_ForStreams(Type type, string contentType) { // Arrange var formatter = new StreamOutputFormatter(); var contentTypeHeader = new StringSegment(contentType); var context = new OutputFormatterWriteContext( new DefaultHttpContext(), new TestHttpResponseStreamWriterFactory().CreateWriter, type, new MemoryStream()) { ContentType = contentTypeHeader, }; // Act var canWrite = formatter.CanWriteResult(context); // Assert Assert.True(canWrite); }