public void NavbarWithRightNav() { var output = new StringBuilder(); var writer = new StringBuilderWriter(output); using (var navbar = new Navbar(writer)) { using (var nav = navbar.Nav()) { writer.Write(nav.Link("Google", "www.google.com")); writer.Write(nav.Link("GitHub", "www.github.com")); } using (var nav = navbar.RightNav()) { writer.Write(nav.Link("Profile", "#")); } } Assert.AreEqual("<nav class=\"navbar navbar-default\" role=\"navigation\"><div class=\"container\">" + "<ul class=\"nav navbar-nav\">" + "<li><a href=\"www.google.com\">Google</a></li>" + "<li><a href=\"www.github.com\">GitHub</a></li>" + "</ul>" + "<ul class=\"nav navbar-nav navbar-right\">" + "<li><a href=\"#\">Profile</a></li>" + "</ul>" + "</div></nav>", output.ToString()); }
public void TestStringBuilderWriter() { var sw = new StringBuilderWriter(); sw = new StringBuilderWriter(1); sw = new StringBuilderWriter(1234); sw = new StringBuilderWriter(-2); sw = new StringBuilderWriter(0); Assert.IsNotNull(sw.FormatProvider); Assert.IsNotNull(sw.NewLine); Assert.IsNotNull(sw.Encoding); Assert.IsTrue(sw.Length == 0); sw.Write("ABC"); Assert.IsTrue(sw.Length == 3); sw.Write('a'); Assert.IsTrue(sw.Length == 4); sw.Write(new char[3] { '1', '1', '2' }, 0, 3); Assert.IsTrue(sw.Length == 7); sw.Write(new char[3] { '1', '1', '2' }); Assert.IsTrue(sw.ToString().Length == 10); }
public static string SerializeToString <T>(T value) { if (value == null || value is Delegate) { return(null); } if (typeof(T) == typeof(object)) { return(SerializeToString(value, value.GetType())); } if (typeof(T).IsAbstract() || typeof(T).IsInterface()) { JsState.IsWritingDynamic = true; var result = SerializeToString(value, value.GetType()); JsState.IsWritingDynamic = false; return(result); } using (var sb = StringBuilderWriter.Create()) { if (typeof(T) == typeof(string)) { JsonUtils.WriteString(sb.Writer, value as string); } else { JsonWriter <T> .WriteRootObject(sb.Writer, value); } return(sb.ToString()); } }
public static string ReturnAndFree(StringBuilderWriter writer) { var ret = writer.ToString(); writer.Clear(); s_Cache = writer; return(ret); }
public void NavbarInverse() { var output = new StringBuilder(); var writer = new StringBuilderWriter(output); using (var navbar = new Navbar(writer, Navbar.Settings.Inverted())) { } Assert.AreEqual("<nav class=\"navbar navbar-default navbar-inverse\" role=\"navigation\"><div class=\"container\"></div></nav>", output.ToString()); }
public void BasicNavbar() { var output = new StringBuilder(); var writer = new StringBuilderWriter(output); using (var navbar = new Navbar(writer)) { } Assert.AreEqual("<nav class=\"navbar navbar-default\" role=\"navigation\"><div class=\"container\"></div></nav>", output.ToString()); }
public void NullHtmlHelperForTestingShouldntBreak() { var output = new StringBuilder(); var writer = new StringBuilderWriter(output); using (var form = new Form(writer, null)) { } Assert.AreEqual("", output.ToString()); }
public static void Dump(this SyntaxNode node, [NotNull] StringBuilder stringBuilder, bool withTrivia = false) { if (stringBuilder == null) { throw new ArgumentNullException(nameof(stringBuilder)); } var writer = new StringBuilderWriter(stringBuilder); node.Dump(writer, withTrivia); writer.Flush(); }
public void EmptyFormGroup() { var output = new StringBuilder(); var writer = new StringBuilderWriter(output); using (var form = new Form(writer, null)) { writer.Write(form.Group()); } Assert.AreEqual("<div class=\"form-group\"></div>", output.ToString()); }
public void NavbarWithButton() { var output = new StringBuilder(); var writer = new StringBuilderWriter(output); using (var navbar = new Navbar(writer)) { writer.Write(navbar.Button("Sign In")); } Assert.AreEqual("<nav class=\"navbar navbar-default\" role=\"navigation\"><div class=\"container\">" + "<button class=\"btn btn-default navbar-btn\">Sign In</button>" + "</div></nav>", output.ToString()); }
public void NavbarWithText() { var output = new StringBuilder(); var writer = new StringBuilderWriter(output); using (var navbar = new Navbar(writer)) { writer.Write(navbar.Text("Signed in as Jordan Wallwork")); } Assert.AreEqual("<nav class=\"navbar navbar-default\" role=\"navigation\"><div class=\"container\">" + "<p class=\"navbar-text\">Signed in as Jordan Wallwork</p>" + "</div></nav>", output.ToString()); }
public void NavbarWithBrandLink() { var output = new StringBuilder(); var writer = new StringBuilderWriter(output); using (var navbar = new Navbar(writer)) { writer.Write(navbar.Brand("BootstrapComponents", "https://github.com/jordanwallwork/bootstrapcomponents")); } Assert.AreEqual("<nav class=\"navbar navbar-default\" role=\"navigation\"><div class=\"container\">" + "<a class=\"navbar-brand\" href=\"https://github.com/jordanwallwork/bootstrapcomponents\">BootstrapComponents</a>" + "</div></nav>", output.ToString()); }
public static StringBuilderWriter Allocate() { var ret = s_Cache; if (ret == null) { return(new StringBuilderWriter(256)); } else { s_Cache = null; //don't re-issue cached instance until it's freed } return(ret); }
public static void Main(string[] args) { IReader reader = new ConsoleReader(); var sbWriter = new StringBuilderWriter(); //IWriter writer = new ConsoleWriter(); //IWriter fileWriter = new FIleWriter(); var engine = new Engine(reader, sbWriter); engine.Run(); Console.WriteLine(sbWriter.sb.ToString().Trim()); }
public void DisabledLinks() { var output = new StringBuilder(); var writer = new StringBuilderWriter(output); using (var nav = new Nav(writer)) { writer.Write(nav.Link("Home", "#", new { @class = "disabled" })); writer.Write(nav.Link("Profile", "#")); } Assert.AreEqual("<ul class=\"nav nav-tabs\">" + "<li class=\"disabled\"><a href=\"#\">Home</a></li>" + "<li><a href=\"#\">Profile</a></li>" + "</ul>", output.ToString()); }
public void IndicateActiveWithExplicitIdentifier() { var output = new StringBuilder(); var writer = new StringBuilderWriter(output); using (var nav = new Nav(writer, "HomeLink", Nav.Settings.Pills())) { writer.Write(nav.Link("Home", "#", "HomeLink")); writer.Write(nav.Link("Profile", "#", "ProfileLink")); } Assert.AreEqual("<ul class=\"nav nav-pills\">" + "<li class=\"active\"><a href=\"#\">Home</a></li>" + "<li><a href=\"#\">Profile</a></li>" + "</ul>", output.ToString()); }
public void Justify() { var output = new StringBuilder(); var writer = new StringBuilderWriter(output); using (var nav = new Nav(writer, Nav.Settings.Justify())) { writer.Write(nav.Link("Home", "#")); writer.Write(nav.Link("Profile", "#")); } Assert.AreEqual("<ul class=\"nav nav-tabs nav-justified\">" + "<li><a href=\"#\">Home</a></li>" + "<li><a href=\"#\">Profile</a></li>" + "</ul>", output.ToString()); }
public void GenerateLabelForScreenReaderIfMissing() { var output = new StringBuilder(); var writer = new StringBuilderWriter(output); using (var form = new Form(writer, null)) { writer.Write(form.Group( fg => fg.TextBox("Email", "*****@*****.**") )); } Assert.AreEqual("<div class=\"form-group\">" + "<input class=\"form-control\" id=\"Email\" type=\"text\" value=\"[email protected]\" />" + "<label class=\"sr-only\" for=\"Email\">Email</label>" + "</div>", output.ToString()); }
public void BasicInputWithLabel() { var output = new StringBuilder(); var writer = new StringBuilderWriter(output); using (var form = new Form(writer, null)) { writer.Write(form.Group( fg => fg.Label("Email"), fg => fg.TextBox("Email", "*****@*****.**") )); } Assert.AreEqual("<div class=\"form-group\">" + "<label for=\"Email\">Email</label>" + "<input class=\"form-control\" id=\"Email\" type=\"text\" value=\"[email protected]\" />" + "</div>", output.ToString()); }
public static void Main(string[] args) { //IReader reader = new ConsoleReader(); //IWriter writer = new ConsoleWriter(); //var engine = new Engine(reader, writer); //engine.Run(); /* Use the below configuration instead of the usual one if you wish to print all output messages together after the inputs for easier comparison with the example output. */ IReader reader = new ConsoleReader(); var sbWriter = new StringBuilderWriter(); var engine = new Engine(reader, sbWriter); engine.Run(); Console.WriteLine(sbWriter.sb.ToString().Trim()); }
public static string SerializeToString(object value, Type type) { if (value == null) { return(null); } if (type == typeof(string)) { return(value as string); } using (var sb = StringBuilderWriter.Create()) { JsvWriter.GetWriteFn(type)(sb.Writer, value); return(sb.ToString()); } }
public static void Main() { IChampionshipController controller = new ChampionshipController(); IReader reader = new ConsoleReader(); //IWriter writer = new ConsoleWriter(); //За по-лесно и по-четимо локално нестване на изходните данни си правим StringBuilderWriter(). //За judge този ред се трие, а горният се откоментира IWriter writer = new StringBuilderWriter(); Engine enigne = new Engine(controller, reader, writer); enigne.Run(); //За локално нестване. При изпращане в judgе, тези редове се изтриват. Console.Clear(); Console.WriteLine(writer); }
public void NavbarWithBrand() { var output = new StringBuilder(); var writer = new StringBuilderWriter(output); using (var navbar = new Navbar(writer)) { using (navbar.Header()) { writer.Write(navbar.Brand("BootstrapComponents")); } } Assert.AreEqual("<nav class=\"navbar navbar-default\" role=\"navigation\"><div class=\"container\">" + "<div class=\"navbar-header\">" + toggleHtml + "<p class=\"navbar-brand\">BootstrapComponents</p>" + "</div>" + "</div></nav>", output.ToString()); }
public CommandLineConsole() { m_stringBuilderWriter = new StringBuilderWriter(); Out = m_stringBuilderWriter; Error = m_stringBuilderWriter; }
public void TestInit() { _writer = new StringBuilderWriter(); _option = new TabPanel(_writer); }
public void TestInit() { _writer = new StringBuilderWriter(); _form = new Form(_writer); }
public void TestInit() { _writer = new StringBuilderWriter(); _option = new LayoutRegion(_writer); }
public void TestInit() { _writer = new StringBuilderWriter(); _layout = new Layout(_writer, false); }