public void DynamicFileResponseWriter_Write_WebServerContext_WritesContent() { //------------Setup for test-------------------------- string content; NameValueCollection boundVars; NameValueCollection queryStr; NameValueCollection headers; var request = WebServerRequestTests.CreateHttpRequest(out content, out boundVars, out queryStr, out headers); var context = new WebServerContext(request, boundVars); const string Token = "%%Token%%"; const string LayoutContentFormat = "<html><body>{0}</body></html>"; const string NewContent = "Hello world"; var responseWriter = new TestDynamicFileResponseWriter(string.Format(LayoutContentFormat, Token), Token, NewContent); //------------Execute Test--------------------------- responseWriter.Write(context); //------------Assert Results------------------------- Assert.AreEqual(ContentTypes.Html, context.ResponseMessage.Content.Headers.ContentType); Assert.IsInstanceOfType(context.ResponseMessage.Content, typeof(StringContent)); var task = context.ResponseMessage.Content.ReadAsStringAsync(); task.Wait(); Assert.AreEqual(string.Format(LayoutContentFormat, NewContent), task.Result); }