public Task TextWriterAddedIfNotPresentInEnvironment() { object actualOutput = null; var encapsulateOutput = new StringWriter(); IList <KeyValuePair <string, object> > data = new[] { new KeyValuePair <string, object>("host.TraceOutput", encapsulateOutput) }; var middleware = new Encapsulate(env => { actualOutput = env["host.TraceOutput"]; return(TaskHelpers.Completed()); }, data); return(middleware.Invoke(CreateEmptyRequest()).Then(() => { actualOutput.ShouldBeSameAs(encapsulateOutput); })); }
public async Task TextWriterNotChangedIfPresent() { object actualOutput = null; var encapsulateOutput = new StringWriter(); var environmentOutput = new StringWriter(); IList <KeyValuePair <string, object> > data = new[] { new KeyValuePair <string, object>("host.TraceOutput", encapsulateOutput) }; var middleware = new Encapsulate(env => { actualOutput = env["host.TraceOutput"]; return(Task.FromResult(0)); }, data); IDictionary <string, object> env2 = CreateEmptyRequest(); env2["host.TraceOutput"] = environmentOutput; await middleware.Invoke(env2); actualOutput.ShouldBeSameAs(environmentOutput); actualOutput.ShouldNotBeSameAs(encapsulateOutput); }