public void TestManualIndent() { // Under normal circunstances you don't need to manual control indentation _w.WriteLine("Line1"); _w.IncreaseIndent(); _w.WriteLine("Line2"); _w.IncreaseIndent(); _w.WriteLine("Line3"); _w.DecreaseIndent(); _w.WriteLine("Line4"); Assert.AreEqual(expectedGeneric, _w.GetContents()); }
private static void WriteToDoList(CodegenTextWriter writer, IEnumerable <TodoItem> todoItems) { foreach (var item in todoItems) { writer.WriteLine("- {0}", item.Description); if (item.SubTasks.Any()) { writer.IncreaseIndent(); WriteToDoList(writer, item.SubTasks); writer.DecreaseIndent(); } } }
public void TestMultiline3() { _w.IncreaseIndent(); // this can also be set by WithIndent, WithCBlock, WithJavaBlock, etc.. and indent is automatically decreased in the end of the block _w.WriteLine(@" public void MyMethod1() { //... }"); _w.DecreaseIndent(); string expected = @" public void MyMethod1() { //... } "; Assert.AreEqual(expected, _w.GetContents()); }