private static void WriterSetCorrectlyInternal(bool throwException) { // Arrange bool triggered = false; HtmlTextWriter writer = new HtmlTextWriter(System.IO.TextWriter.Null); MockViewPage vp = new MockViewPage(); vp.RenderCallback = delegate() { triggered = true; Assert.AreEqual(writer, vp.Writer); if (throwException) { throw new CallbackException(); } }; // Act & Assert Assert.IsNull(vp.Writer); try { vp.RenderControl(writer); } catch (CallbackException) { } Assert.IsNull(vp.Writer); Assert.IsTrue(triggered); }
public void GetWriterFromViewPage() { // Arrange bool triggered = false; HtmlTextWriter writer = new HtmlTextWriter(System.IO.TextWriter.Null); ViewMasterPage vmp = new ViewMasterPage(); MockViewPage vp = new MockViewPage(); vp.RenderCallback = delegate() { triggered = true; Assert.AreEqual(writer, vmp.Writer); }; vmp.Page = vp; // Act & Assert Assert.IsNull(vmp.Writer); vp.RenderControl(writer); Assert.IsNull(vmp.Writer); Assert.IsTrue(triggered); }
private static void WriterSetCorrectlyInternal(bool throwException) { // Arrange bool triggered = false; HtmlTextWriter writer = new HtmlTextWriter(System.IO.TextWriter.Null); MockViewPage vp = new MockViewPage(); vp.RenderCallback = delegate() { triggered = true; Assert.AreEqual(writer, vp.Writer); if (throwException) { throw new CallbackException(); } }; // Act & Assert Assert.IsNull(vp.Writer); try { vp.RenderControl(writer); } catch (CallbackException) { } Assert.IsNull(vp.Writer); Assert.IsTrue(triggered); }