Skip to content

Instantly share code, notes, and snippets.

@KevM
Created September 8, 2011 19:12
Show Gist options
  • Select an option

  • Save KevM/1204390 to your computer and use it in GitHub Desktop.

Select an option

Save KevM/1204390 to your computer and use it in GitHub Desktop.
spark render html behavior invoke test
public class FakeWriter : TextWriter
{
public object Written { get; set; }
public override void Write(object value)
{
Written = value;
}
public override Encoding Encoding
{
get { return new ASCIIEncoding(); }
}
}
[TestFixture]
public class InvokePartial_SparkRenderHtmlBehavior : InteractionContext<SparkRenderHtmlBehavior<ActionOutputType>>
{
private ActionOutputType _outputType;
private FakeWriter _nestedOutputWriter;
protected override void beforeEach()
{
_outputType = new ActionOutputType();
MockFor<IFubuRequest>().Stub(a => a.Get<ActionOutputType>()).Return(_outputType);
var nestedOutput = new NestedOutput();
_nestedOutputWriter = new FakeWriter();
nestedOutput.SetWriter(()=>_nestedOutputWriter);
Services.Inject(nestedOutput);
ClassUnderTest.InvokePartial();
}
[Test]
public void should_get_the_output_model()
{
MockFor<IFubuRequest>().AssertWasCalled(a => a.Get<ActionOutputType>());
}
[Test]
public void should_write_to_the_the_output_writer()
{
_nestedOutputWriter.Written.ShouldBeTheSameAs(_outputType);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment