コード例 #1
0
        public void ParameterList_NoParameters()
        {
            var parameters = Lists.NewList <IParameterName>();
            var sut        = new SSTPrintingContext();

            sut.ParameterList(parameters);
            Assert.AreEqual("()", sut.ToString());
        }
コード例 #2
0
        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());
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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());
        }
コード例 #5
0
        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());
        }
コード例 #6
0
        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());
        }
コード例 #7
0
        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());
        }
コード例 #8
0
 protected void AssertPrintWithCustomContext(ISSTNode sst, SSTPrintingContext context, params string[] expectedLines)
 {
     AssertPrintWithCustomContext(sst, context, String.Join(Environment.NewLine, expectedLines));
 }
コード例 #9
0
        private static void AssertTypeFormat(string expected, string typeIdentifier)
        {
            var sut = new SSTPrintingContext();

            Assert.AreEqual(expected, sut.Type(Names.Type(typeIdentifier)).ToString());
        }