public void ParameterList_NoParameters() { var parameters = Lists.NewList <IParameterName>(); var sut = new SSTPrintingContext(); sut.ParameterList(parameters); Assert.AreEqual("()", sut.ToString()); }
public void StatementBlock_Empty_WithBrackets() { var stmts = Lists.NewList <IStatement>(); var visitor = new SSTPrintingVisitor(); var sut = new SSTPrintingContext(); sut.StatementBlock(stmts, visitor); Assert.AreEqual(" { }", sut.ToString()); }
protected void AssertPrintWithCustomContext(ISSTNode sst, SSTPrintingContext context, string expected) { var indentationLevel = context.IndentationLevel; sst.Accept(_sut, context); var actual = context.ToString(); Assert.AreEqual(expected, actual); Assert.AreEqual(indentationLevel, context.IndentationLevel); }
public void ParameterList_MultipleParameters() { var parameters = new KaVEList <IParameterName> { Names.Parameter("[A,P] p1"), Names.Parameter("[B,P] p2") }; var sut = new SSTPrintingContext(); sut.ParameterList(parameters); Assert.AreEqual("(A p1, B p2)", sut.ToString()); }
public void UnknownNameAndGlobalNamespaceAreNotAddedToList() { var namespaces = Sets.NewHashSet <INamespaceName>(); namespaces.Add(Names.UnknownNamespace); namespaces.Add(Names.Namespace("")); var context = new SSTPrintingContext(); namespaces.FormatAsUsingList(context); const string expected = ""; Assert.AreEqual(expected, context.ToString()); }
public void StatementBlock_NotEmpty_WithoutBrackets() { var stmts = new KaVEList <IStatement> { new ContinueStatement(), new BreakStatement() }; var visitor = new SSTPrintingVisitor(); var sut = new SSTPrintingContext(); var expected = String.Join( Environment.NewLine, "", " continue;", " break;"); sut.StatementBlock(stmts, visitor, false); Assert.AreEqual(expected, sut.ToString()); }
public void UsingListFormattedCorrectly() { var namespaces = Sets.NewHashSet <INamespaceName>(); namespaces.Add(Names.Namespace("Z")); namespaces.Add(Names.Namespace("System")); namespaces.Add(Names.Namespace("System")); namespaces.Add(Names.Namespace("System.Collections.Generic")); namespaces.Add(Names.Namespace("A")); namespaces.Add(Names.Namespace("")); var context = new SSTPrintingContext(); namespaces.FormatAsUsingList(context); var expected = string.Join( Environment.NewLine, "using A;", "using System;", "using System.Collections.Generic;", "using Z;"); Assert.AreEqual(expected, context.ToString()); }
protected void AssertPrintWithCustomContext(ISSTNode sst, SSTPrintingContext context, params string[] expectedLines) { AssertPrintWithCustomContext(sst, context, String.Join(Environment.NewLine, expectedLines)); }
private static void AssertTypeFormat(string expected, string typeIdentifier) { var sut = new SSTPrintingContext(); Assert.AreEqual(expected, sut.Type(Names.Type(typeIdentifier)).ToString()); }