コード例 #1
0
        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);
        }
コード例 #5
0
 public TSIntersectionType(TSBuilder builder)
 {
     this.builder = builder;
     currentState = State.Start;
 }
コード例 #6
0
 public TSDocumentationComment(TSBuilder builder)
 {
     this.builder          = builder;
     previousWordWrapWidth = builder.WordWrapWidth;
 }
コード例 #7
0
 /// <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;
 }
コード例 #8
0
 public TSBlock(TSBuilder builder)
 {
     this.builder = builder;
     currentState = State.Start;
 }
コード例 #9
0
 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));
        }
コード例 #12
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>();
 }
コード例 #21
0
 public TSInterface(TSBuilder builder)
 {
     this.builder = builder;
     currentState = State.Start;
 }