コード例 #1
0
        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());
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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());
            }
        }
コード例 #4
0
        public static string ReturnAndFree(StringBuilderWriter writer)
        {
            var ret = writer.ToString();

            writer.Clear();
            s_Cache = writer;
            return(ret);
        }
コード例 #5
0
        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());
        }
コード例 #6
0
        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());
        }
コード例 #7
0
        public void NullHtmlHelperForTestingShouldntBreak()
        {
            var output = new StringBuilder();
            var writer = new StringBuilderWriter(output);

            using (var form = new Form(writer, null))
            {
            }
            Assert.AreEqual("", output.ToString());
        }
コード例 #8
0
        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();
        }
コード例 #9
0
        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());
        }
コード例 #10
0
        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());
        }
コード例 #11
0
        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());
        }
コード例 #12
0
        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());
        }
コード例 #13
0
        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);
        }
コード例 #14
0
        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());
        }
コード例 #15
0
        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());
        }
コード例 #16
0
        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());
        }
コード例 #17
0
        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());
        }
コード例 #18
0
        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());
        }
コード例 #19
0
        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());
        }
コード例 #20
0
        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());
        }
コード例 #21
0
        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());
            }
        }
コード例 #22
0
        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);
        }
コード例 #23
0
        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());
        }
コード例 #24
0
 public CommandLineConsole()
 {
     m_stringBuilderWriter = new StringBuilderWriter();
     Out   = m_stringBuilderWriter;
     Error = m_stringBuilderWriter;
 }
コード例 #25
0
ファイル: TabPanelTest.cs プロジェクト: K-Artisan/Project-01
 public void TestInit()
 {
     _writer = new StringBuilderWriter();
     _option = new TabPanel(_writer);
 }
コード例 #26
0
ファイル: FormTest.cs プロジェクト: K-Artisan/Project-01
 public void TestInit()
 {
     _writer = new StringBuilderWriter();
     _form   = new Form(_writer);
 }
コード例 #27
0
 public void TestInit()
 {
     _writer = new StringBuilderWriter();
     _option = new LayoutRegion(_writer);
 }
コード例 #28
0
 public void TestInit()
 {
     _writer = new StringBuilderWriter();
     _layout = new Layout(_writer, false);
 }