public void NestedIfBlocks() { TSBuilder builder = new TSBuilder(); builder.If("a", ifBlock1 => { ifBlock1.If("b", ifBlock2 => { }); }); AssertEx.EqualLines( new[] { "if (a) {", " if (b) {", " }", "}" }, builder); }
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()); }
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); }
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) { }
public TSObjectType(TSBuilder builder) { this.builder = builder; currentState = State.Start; }
public void HasChangedLinesSinceWithZeroIndexAndEmptyBuilder() { TSBuilder builder = new TSBuilder(); Assert.IsFalse(builder.HasChangedLinesSince(0)); }
public void Constructor() { TSBuilder builder = new TSBuilder(); Assert.AreEqual("", builder.ToString()); }
public TSIfBlock(TSBuilder builder) : base(builder) { }
/// <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; }
/// <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; }
/// <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; }
public void HasChangedLinesSinceWithNegativeIndexAndEmptyBuilder() { TSBuilder builder = new TSBuilder(); Assert.ThrowsException <IndexOutOfRangeException>(() => builder.HasChangedLinesSince(-1)); }
/// <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; }
/// <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(); }
/// <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; }