protected override void WriteHtml(HtmlTextWriter writer) { Guard.IsNotNull(writer, "writer"); IWindowHtmlBuilder builder = builderFactory.Create(this); IHtmlNode windowTag = builder.WindowTag(); //Header IHtmlNode headerTag = builder.HeaderTag().AppendTo(windowTag); builder.TitleTag().AppendTo(headerTag); if (Buttons.Container.Count > 0) { IHtmlNode buttonContainerTag = builder.ButtonContainerTag().AppendTo(headerTag); Buttons.Container.Each(button => builder.ButtonTag(button).AppendTo(buttonContainerTag)); } //Content builder.ContentTag().AppendTo(windowTag); //output window HTML windowTag.WriteTo(writer); base.WriteHtml(writer); }
public static Window CreateWindow(IWindowHtmlBuilder renderer) { Mock <HttpContextBase> httpContext = TestHelper.CreateMockedHttpContext(); httpContext.Setup(c => c.Request.Browser.CreateHtmlTextWriter(It.IsAny <TextWriter>())).Returns(new HtmlTextWriter(TextWriter.Null)); Mock <IWindowHtmlBuilderFactory> windowHtmlBuilderFactory = new Mock <IWindowHtmlBuilderFactory>(); Mock <IClientSideObjectWriterFactory> clientSideObjectWriterFactory = new Mock <IClientSideObjectWriterFactory>(); clientSideObjectWriter = new Mock <IClientSideObjectWriter>(); Mock <IUrlGenerator> urlGenerator = new Mock <IUrlGenerator>(); ViewContext viewContext = TestHelper.CreateViewContext(); clientSideObjectWriterFactory.Setup(c => c.Create(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <TextWriter>())).Returns(clientSideObjectWriter.Object); Window window = new Window(viewContext, clientSideObjectWriterFactory.Object, windowHtmlBuilderFactory.Object); renderer = renderer ?? new WindowHtmlBuilder(window); windowHtmlBuilderFactory.Setup(f => f.Create(It.IsAny <Window>())).Returns(renderer); return(window); }
public void Should_be_able_to_create_renderer() { WindowHtmlBuilderFactory factory = new WindowHtmlBuilderFactory(); IWindowHtmlBuilder renderer = factory.Create(WindowTestHelper.CreateWindow(null)); Assert.IsType <WindowHtmlBuilder>(renderer); }
public static Window CreateWindow(IWindowHtmlBuilder renderer) { Mock<HttpContextBase> httpContext = TestHelper.CreateMockedHttpContext(); httpContext.Setup(c => c.Request.Browser.CreateHtmlTextWriter(It.IsAny<TextWriter>())).Returns(new HtmlTextWriter(TextWriter.Null)); Mock<IWindowHtmlBuilderFactory> windowHtmlBuilderFactory = new Mock<IWindowHtmlBuilderFactory>(); Mock<IClientSideObjectWriterFactory> clientSideObjectWriterFactory = new Mock<IClientSideObjectWriterFactory>(); clientSideObjectWriter = new Mock<IClientSideObjectWriter>(); Mock<IUrlGenerator> urlGenerator = new Mock<IUrlGenerator>(); ViewContext viewContext = TestHelper.CreateViewContext(); clientSideObjectWriterFactory.Setup(c => c.Create(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<TextWriter>())).Returns(clientSideObjectWriter.Object); Window window = new Window(viewContext, clientSideObjectWriterFactory.Object, windowHtmlBuilderFactory.Object); renderer = renderer ?? new WindowHtmlBuilder(window); windowHtmlBuilderFactory.Setup(f => f.Create(It.IsAny<Window>())).Returns(renderer); return window; }
public WindowHtmlBuilderTests() { window = WindowTestHelper.CreateWindow(null); renderer = new WindowHtmlBuilder(window); window.Name = "Window"; }