public void NestedIfBlocks()
        {
            TSBuilder builder = new TSBuilder();

            builder.If("a", ifBlock1 =>
            {
                ifBlock1.If("b", ifBlock2 =>
                {
                });
            });
            AssertEx.EqualLines(
                new[]
            {
                "if (a) {",
                "  if (b) {",
                "  }",
                "}"
            },
                builder);
        }
示例#2
0
        public void IfBlockInTryBlock()
        {
            TSBuilder builder = new TSBuilder();

            builder.Try(tryBlock =>
            {
                tryBlock.If("true", ifBlock =>
                {
                });
            })
            .Catch("error", catchBlock1 =>
            {
            });
            AssertEx.EqualLines(
                "try {" + Environment.NewLine +
                "  if (true) {" + Environment.NewLine +
                "  }" + Environment.NewLine +
                "} catch (error) {" + Environment.NewLine +
                "}",
                builder.ToString());
        }
示例#3
0
        public void DocumentationCommentWithWrappedDescription()
        {
            TSBuilder builder = new TSBuilder(10);

            builder.DocumentationComment(comment =>
            {
                comment.Description("This is my long description that will get wrapped.");
            });
            // The AutoRest WordWrap() function seems to include the trailing newline character in
            // its wordwrap algorithm. " * This is" is 10 characters long, so it shouldn't get
            // wrapped, but AutoRest WordWrap() wraps it.
            AssertEx.EqualLines(
                "/**\n" +
                " * This\n" +
                " * is my\n" +
                " * long\n" +
                " * description\n" +
                " * that\n" +
                " * will\n" +
                " * get\n" +
                " * wrapped.\n" +
                " */",
                builder);
        }
示例#4
0
        public void IfElseIfWithTextBlocks()
        {
            TSBuilder builder = new TSBuilder();

            builder.If("true", ifBlock =>
            {
                ifBlock.Text("Hello");
            })
            .ElseIf("false", elseBlock =>
            {
                elseBlock.Text("World");
            });
            AssertEx.EqualLines(
                new[]
            {
                "if (true) {",
                "  Hello",
                "} else if (false) {",
                "  World",
                "}"
            },
                builder);
            Assert.IsTrue(builder.WriteNewLineBeforeNextText);
        }
 public TSIntersectionType(TSBuilder builder)
 {
     this.builder = builder;
     currentState = State.Start;
 }
 public TSDocumentationComment(TSBuilder builder)
 {
     this.builder          = builder;
     previousWordWrapWidth = builder.WordWrapWidth;
 }
 /// <summary>
 /// Create a new JSON object.
 /// </summary>
 /// <param name="builder">The TSBuilder that this TSObject will emit to.</param>
 public TSObject(TSBuilder builder)
 {
     this.builder = builder;
 }
 public TSBlock(TSBuilder builder)
 {
     this.builder = builder;
     currentState = State.Start;
 }
 public TSTryBlock(TSBuilder builder)
     : base(builder)
 {
 }
示例#10
0
 public TSObjectType(TSBuilder builder)
 {
     this.builder = builder;
     currentState = State.Start;
 }
示例#11
0
        public void HasChangedLinesSinceWithZeroIndexAndEmptyBuilder()
        {
            TSBuilder builder = new TSBuilder();

            Assert.IsFalse(builder.HasChangedLinesSince(0));
        }
        public void Constructor()
        {
            TSBuilder builder = new TSBuilder();

            Assert.AreEqual("", builder.ToString());
        }
示例#13
0
 public TSIfBlock(TSBuilder builder)
     : base(builder)
 {
 }
示例#14
0
 /// <summary>
 /// Create a new TSValue that will emit to the provided TSBuilder.
 /// </summary>
 /// <param name="builder">The TSBuilder this TSValue will emit to.</param>
 public TSValue(TSBuilder builder)
 {
     this.builder = builder;
 }
示例#15
0
 /// <summary>
 /// Create a new parameter list builder.
 /// </summary>
 /// <param name="builder">The TSBuilder that will be used to collect the generated text.</param>
 public TSParameterList(TSBuilder builder)
 {
     this.builder = builder;
 }
示例#16
0
 /// <summary>
 /// Create a new JSON array.
 /// </summary>
 /// <param name="builder">The TSBuilder that this TSArray will emit to.</param>
 public TSArray(TSBuilder builder)
 {
     this.builder = builder;
 }
示例#17
0
        public void HasChangedLinesSinceWithNegativeIndexAndEmptyBuilder()
        {
            TSBuilder builder = new TSBuilder();

            Assert.ThrowsException <IndexOutOfRangeException>(() => builder.HasChangedLinesSince(-1));
        }
示例#18
0
 /// <summary>
 /// Create a new export object.
 /// </summary>
 /// <param name="builder">The TSBuilder that this TSExport will emit to.</param>
 public TSExport(TSBuilder builder)
 {
     this.builder = builder;
 }
示例#19
0
 /// <summary>
 /// Create a new TSFile at the provided file path.
 /// </summary>
 /// <param name="filePath">The file path that the TSFile will be created at.</param>
 public TSFile(string filePath)
 {
     FilePath = filePath;
     builder  = new TSBuilder();
 }
示例#20
0
 /// <summary>
 /// Create a new TSArgumentList that will emit text to the provided TSBuilder.
 /// </summary>
 /// <param name="builder">The TSBuilder to emit text to.</param>
 public TSArgumentList(TSBuilder builder)
     : base(builder)
 {
     argumentPositions = new List <TSPosition>();
 }
 public TSInterface(TSBuilder builder)
 {
     this.builder = builder;
     currentState = State.Start;
 }