コード例 #1
0
        private void AssertReturn(ISSTNode node)
        {
            var       actual   = node.Accept(_sut, DefaultArgument);
            const int expected = 0;

            Assert.AreEqual(expected, actual);
        }
コード例 #2
0
 private void TestPrintingWithoutIndentation(ISSTNode sst, string[] expectedLines)
 {
     AssertPrintWithCustomContext(
         sst,
         new SSTPrintingContext {
         IndentationLevel = 0
     },
         expectedLines);
 }
コード例 #3
0
        private void TestPrintingWithHighlightingProducesValidXaml(ISSTNode sst)
        {
            var context = new XamlSSTPrintingContext();

            sst.Accept(_sut, context);
            var actual = context.ToString();

            // throws and fails test if markup is invalid
            XamlUtils.CreateDataTemplateFromXaml(actual);
        }
コード例 #4
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);
        }
コード例 #5
0
        private void TestPrintingWithIndentation(ISSTNode sst, IEnumerable <string> expectedLines)
        {
            var indentedLines = expectedLines.Select(line => String.IsNullOrEmpty(line) ? line : "    " + line);

            AssertPrintWithCustomContext(
                sst,
                new SSTPrintingContext {
                IndentationLevel = 1
            },
                indentedLines.ToArray());
        }
コード例 #6
0
        protected void AssertPrint(ISSTNode sst, params string[] expectedLines)
        {
            TestPrintingWithoutIndentation(sst, expectedLines);
            TestPrintingWithHighlightingProducesValidXaml(sst);

            // Expressions and references can't be indented
            if (!(sst is IExpression || sst is IReference))
            {
                TestPrintingWithIndentation(sst, expectedLines);
            }
        }
コード例 #7
0
        protected static void AssertChildren(ISSTNode sut, params ISSTNode[] expecteds)
        {
            var actualsEnum   = sut.Children.GetEnumerator();
            var expectedsEnum = expecteds.GetEnumerator();

            while (expectedsEnum.MoveNext())
            {
                Assert.True(actualsEnum.MoveNext());
                // ReSharper disable once PossibleUnintendedReferenceComparison
                Assert.True(expectedsEnum.Current == actualsEnum.Current);
            }
            Assert.False(actualsEnum.MoveNext());
        }
コード例 #8
0
 private void AssertAccept(ISSTNode node)
 {
     Mock.Get(node).Verify(n => n.Accept(_sut, DefaultArgument));
 }
コード例 #9
0
 private void Visit(ISSTNode node)
 {
     node.Accept(_sut, DefaultArgument);
 }
コード例 #10
0
 public VisitorAssertion(ISSTNode node, int context)
 {
     _node    = node;
     _context = context;
 }
コード例 #11
0
 public static VisitorAssertion Accept(this ISSTNode node, int context)
 {
     return(new VisitorAssertion(node, context));
 }
コード例 #12
0
        private void AssertAnonymization(ISSTNode expr, ISSTNode expected)
        {
            var actual = expr.Accept(_sut, 0);

            Assert.AreEqual(expected, actual);
        }
コード例 #13
0
 protected void AssertPrintWithCustomContext(ISSTNode sst, SSTPrintingContext context, params string[] expectedLines)
 {
     AssertPrintWithCustomContext(sst, context, String.Join(Environment.NewLine, expectedLines));
 }