예제 #1
0
        public void InterfaceIndent()
        {
            var c = new Interface("IPerson");

            var cs = new CSharpSourceCodeGenerator();
            cs.CurrentIndentLevel = 2;
            cs.Write(c);
            //static prefer
            Assert.AreEqual("        public interface IPerson" + SourceCodeGenerator.NewLine
                + "        {" + SourceCodeGenerator.NewLine
                + "        }" + SourceCodeGenerator.NewLine, cs.ToString());
        }
예제 #2
0
        public void InterfaceIndent()
        {
            var c = new Interface("IPerson");

            var cs = new CSharpSourceCodeGenerator();

            cs.CurrentIndentLevel = 2;
            cs.Write(c);
            //static prefer
            Assert.AreEqual("        public interface IPerson" + SourceCodeGenerator.NewLine
                            + "        {" + SourceCodeGenerator.NewLine
                            + "        }" + SourceCodeGenerator.NewLine, cs.ToString());
        }
예제 #3
0
        public void TestPropertyBasicFeature()
        {
            var p = new PropertyBody(PropertyBodyType.Get);
            p.Body.Add(new CodeBlock(SourceCodeLanguage.CSharp, "return _Age;"));

            var cs = new CSharpSourceCodeGenerator();
            cs.CurrentIndentLevel = 1;
            cs.Write(p);

            Assert.AreEqual("    get" + SourceCodeGenerator.NewLine
                + "    {" + SourceCodeGenerator.NewLine
                + "        return _Age;" + SourceCodeGenerator.NewLine
                + "    }" + SourceCodeGenerator.NewLine
                , cs.ToString());
        }
예제 #4
0
        public void ClassIndent()
        {
            var c = new Class(AccessModifier.Public, "StringUtility");
            c.Modifier.Static = true;
            c.Modifier.Abstract = true;

            CSharpSourceCodeGenerator sc = new CSharpSourceCodeGenerator();
            sc.CurrentIndentLevel = 2;
            sc.Write(c);

            Assert.AreEqual("        public static class StringUtility" + SourceCodeGenerator.NewLine
                + "        {" + SourceCodeGenerator.NewLine
                + "        }" + SourceCodeGenerator.NewLine
                , sc.ToString());
        }
예제 #5
0
        public void CodeBlockIndentIsTwoWhitespace()
        {
            var cb = new CodeBlock(SourceCodeLanguage.CSharp, "if (bl == true)");
            cb.CurlyBracket = true;
            cb.CodeBlocks.Add(new CodeBlock(SourceCodeLanguage.CSharp, "MessageBox.Show(\"Update successfully!\");"));

            var cs = new CSharpSourceCodeGenerator();
            cs.Indent = "  ";
            cs.Write(cb);

            Assert.AreEqual("if (bl == true)" + SourceCodeGenerator.NewLine
                + "{" + SourceCodeGenerator.NewLine
                + "  MessageBox.Show(\"Update successfully!\");" + SourceCodeGenerator.NewLine
                + "}" + SourceCodeGenerator.NewLine
                , cs.ToString());
        }
예제 #6
0
        public void TestPropertyBasicFeature()
        {
            var p = new PropertyBody(PropertyBodyType.Get);

            p.Body.Add(new CodeBlock(SourceCodeLanguage.CSharp, "return _Age;"));

            var cs = new CSharpSourceCodeGenerator();

            cs.CurrentIndentLevel = 1;
            cs.Write(p);

            Assert.AreEqual("    get" + SourceCodeGenerator.NewLine
                            + "    {" + SourceCodeGenerator.NewLine
                            + "        return _Age;" + SourceCodeGenerator.NewLine
                            + "    }" + SourceCodeGenerator.NewLine
                            , cs.ToString());
        }
예제 #7
0
        public void ClassIndent()
        {
            var c = new Class(AccessModifier.Public, "StringUtility");

            c.Modifier.Static   = true;
            c.Modifier.Abstract = true;

            CSharpSourceCodeGenerator sc = new CSharpSourceCodeGenerator();

            sc.CurrentIndentLevel = 2;
            sc.Write(c);

            Assert.AreEqual("        public static class StringUtility" + SourceCodeGenerator.NewLine
                            + "        {" + SourceCodeGenerator.NewLine
                            + "        }" + SourceCodeGenerator.NewLine
                            , sc.ToString());
        }
예제 #8
0
        public void CodeBlockBracket()
        {
            var cb = new CodeBlock(SourceCodeLanguage.CSharp, "catch (InvalidCastException ex)");
            cb.CurlyBracket = true;
            cb.CodeBlocks.Add(new CodeBlock(SourceCodeLanguage.CSharp, "throw new StoredProcedureSchemaMismatchedException(this, ex);"));

            var cs = new CSharpSourceCodeGenerator();
            cs.CurrentIndentLevel = 3;
            cs.Indent = "    ";
            cs.Write(cb);

            Assert.AreEqual("            catch (InvalidCastException ex)" + SourceCodeGenerator.NewLine
                + "            {" + SourceCodeGenerator.NewLine
                + "                throw new StoredProcedureSchemaMismatchedException(this, ex);" + SourceCodeGenerator.NewLine
                + "            }" + SourceCodeGenerator.NewLine
                , cs.ToString());
        }
예제 #9
0
        public void CodeBlockIndentIsTwoWhitespace()
        {
            var cb = new CodeBlock(SourceCodeLanguage.CSharp, "if (bl == true)");

            cb.CurlyBracket = true;
            cb.CodeBlocks.Add(new CodeBlock(SourceCodeLanguage.CSharp, "MessageBox.Show(\"Update successfully!\");"));

            var cs = new CSharpSourceCodeGenerator();

            cs.Indent = "  ";
            cs.Write(cb);

            Assert.AreEqual("if (bl == true)" + SourceCodeGenerator.NewLine
                            + "{" + SourceCodeGenerator.NewLine
                            + "  MessageBox.Show(\"Update successfully!\");" + SourceCodeGenerator.NewLine
                            + "}" + SourceCodeGenerator.NewLine
                            , cs.ToString());
        }
예제 #10
0
        public void CodeBlockBracket()
        {
            var cb = new CodeBlock(SourceCodeLanguage.CSharp, "catch (InvalidCastException ex)");

            cb.CurlyBracket = true;
            cb.CodeBlocks.Add(new CodeBlock(SourceCodeLanguage.CSharp, "throw new StoredProcedureSchemaMismatchedException(this, ex);"));

            var cs = new CSharpSourceCodeGenerator();

            cs.CurrentIndentLevel = 3;
            cs.Indent             = "    ";
            cs.Write(cb);

            Assert.AreEqual("            catch (InvalidCastException ex)" + SourceCodeGenerator.NewLine
                            + "            {" + SourceCodeGenerator.NewLine
                            + "                throw new StoredProcedureSchemaMismatchedException(this, ex);" + SourceCodeGenerator.NewLine
                            + "            }" + SourceCodeGenerator.NewLine
                            , cs.ToString());
        }