[Theory, InlineData('[', ']'), InlineData('(', '}'), InlineData('{', ']')] // Using ) confuses the test explorer... public void TestInner(char left, char right) => TestOuter($@"\left{left}x\right{right}", 1, 14, 4, 30, TestList(1, 14, 4, 30, 0, 0, LinePosition.Regular, Range.UndefinedInt, d => { var glyph = Assert.IsType <GlyphDisplay <TFont, TGlyph> >(d); Assert.Equal(new PointF(), glyph.Position); Assert.Equal(Range.NotFound, glyph.Range); Assert.False(glyph.HasScript); Assert.Equal(left, glyph.Glyph); }, TestList(1, 14, 4, 10, 10, 0, LinePosition.Regular, Range.UndefinedInt, d => { var line = Assert.IsType <TextLineDisplay <TFont, TGlyph> >(d); Assert.Single(line.Atoms); AssertText("x", line); Assert.Equal(new PointF(), line.Position); Assert.False(line.HasScript); }), d => { var glyph2 = Assert.IsType <GlyphDisplay <TFont, TGlyph> >(d); Approximately.At(20, 0, glyph2.Position); Assert.Equal(Range.NotFound, glyph2.Range); Assert.False(glyph2.HasScript); Assert.Equal(right, glyph2.Glyph); }));
System.Action <IDisplay <TFont, TGlyph> > TestList(int rangeMax, double ascent, double descent, double width, double x, double y, LinePosition linePos, int indexInParent, params System.Action <IDisplay <TFont, TGlyph> >[] inspectors) => d => { var list = Assert.IsType <ListDisplay <TFont, TGlyph> >(d); Assert.False(list.HasScript); Assert.Equal(new Range(0, rangeMax), list.Range); Approximately.Equal(ascent, list.Ascent); Approximately.Equal(descent, list.Descent); Approximately.Equal(width, list.Width); Approximately.At(x, y, list.Position); // may change as we implement more details? Assert.Equal(linePos, list.LinePosition); Assert.Equal(indexInParent, list.IndexInParent); Assert.Collection(list.Displays, inspectors); };
public void TestBinomial(string latex) => TestOuter(latex, 1, 27.54, 17.72, 30, TestList(1, 27.54, 17.72, 30, 0, 0, LinePosition.Regular, Range.UndefinedInt, d => { var glyph = Assert.IsType <GlyphDisplay <TFont, TGlyph> >(d); Assert.Equal(new PointF(), glyph.Position); Assert.Equal(Range.NotFound, glyph.Range); Assert.False(glyph.HasScript); }, d => { var subFraction = Assert.IsType <FractionDisplay <TFont, TGlyph> >(d); Assert.Equal(new Range(0, 1), subFraction.Range); Assert.False(subFraction.HasScript); Approximately.At(10, 0, subFraction.Position); TestList(1, 14, 4, 10, 10, 13.54, LinePosition.Regular, Range.UndefinedInt, dd => { var subNumerator = Assert.IsType <TextLineDisplay <TFont, TGlyph> >(dd); Assert.Single(subNumerator.Atoms); AssertText("1", subNumerator); Assert.Equal(new PointF(), subNumerator.Position); Assert.Equal(new Range(0, 1), subNumerator.Range); Assert.False(subNumerator.HasScript); })(subFraction.Numerator); TestList(1, 14, 4, 10, 10, -13.72, LinePosition.Regular, Range.UndefinedInt, dd => { var subDenominator = Assert.IsType <TextLineDisplay <TFont, TGlyph> >(dd); Assert.Single(subDenominator.Atoms); AssertText("3", subDenominator); Assert.Equal(new PointF(), subDenominator.Position); Assert.Equal(new Range(0, 1), subDenominator.Range); Assert.False(subDenominator.HasScript); })(subFraction.Denominator); }, d => { var subRight = Assert.IsType <GlyphDisplay <TFont, TGlyph> >(d); Assert.False(subRight.HasScript); Assert.Equal(Range.NotFound, subRight.Range); Approximately.At(20, 0, subRight.Position); }));