Created
September 8, 2011 19:12
-
-
Save KevM/1204390 to your computer and use it in GitHub Desktop.
spark render html behavior invoke test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [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