Skip to content

Commit

Permalink
Added new tests/examples
Browse files Browse the repository at this point in the history
  • Loading branch information
falleretic committed Feb 29, 2024
1 parent c4ceb99 commit 449afb5
Show file tree
Hide file tree
Showing 13 changed files with 223 additions and 118 deletions.
2 changes: 1 addition & 1 deletion Examples/ApiExamples/ApiExamples/ExCertificateHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ public void Create()
//ExEnd
}
}
}
}
30 changes: 15 additions & 15 deletions Examples/ApiExamples/ApiExamples/ExCharts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ public void AxisProperties()
xAxis.MinorTickMark = AxisTickMark.Cross;
xAxis.MajorUnit = 10.0d;
xAxis.MinorUnit = 15.0d;
xAxis.TickLabelOffset = 50;
xAxis.TickLabelPosition = AxisTickLabelPosition.Low;
xAxis.TickLabelSpacingIsAuto = false;
xAxis.TickLabels.Offset = 50;
xAxis.TickLabels.Position = AxisTickLabelPosition.Low;
xAxis.TickLabels.IsAutoSpacing = false;
xAxis.TickMarkSpacing = 1;

ChartAxis yAxis = chart.AxisY;
Expand All @@ -170,7 +170,7 @@ public void AxisProperties()
yAxis.MinorTickMark = AxisTickMark.Cross;
yAxis.MajorUnit = 100.0d;
yAxis.MinorUnit = 20.0d;
yAxis.TickLabelPosition = AxisTickLabelPosition.NextToAxis;
yAxis.TickLabels.Position = AxisTickLabelPosition.NextToAxis;

// Column charts do not have a Z-axis.
Assert.Null(chart.AxisZ);
Expand All @@ -188,9 +188,9 @@ public void AxisProperties()
Assert.AreEqual(AxisTickMark.Cross, chart.AxisX.MinorTickMark);
Assert.AreEqual(1.0d, chart.AxisX.MajorUnit);
Assert.AreEqual(0.5d, chart.AxisX.MinorUnit);
Assert.AreEqual(50, chart.AxisX.TickLabelOffset);
Assert.AreEqual(AxisTickLabelPosition.Low, chart.AxisX.TickLabelPosition);
Assert.False(chart.AxisX.TickLabelSpacingIsAuto);
Assert.AreEqual(50, chart.AxisX.TickLabels.Offset);
Assert.AreEqual(AxisTickLabelPosition.Low, chart.AxisX.TickLabels.Position);
Assert.False(chart.AxisX.TickLabels.IsAutoSpacing);
Assert.AreEqual(1, chart.AxisX.TickMarkSpacing);

Assert.AreEqual(AxisCategoryType.Category, chart.AxisY.CategoryType);
Expand All @@ -200,7 +200,7 @@ public void AxisProperties()
Assert.AreEqual(AxisTickMark.Cross, chart.AxisY.MinorTickMark);
Assert.AreEqual(100.0d, chart.AxisY.MajorUnit);
Assert.AreEqual(20.0d, chart.AxisY.MinorUnit);
Assert.AreEqual(AxisTickLabelPosition.NextToAxis, chart.AxisY.TickLabelPosition);
Assert.AreEqual(AxisTickLabelPosition.NextToAxis, chart.AxisY.TickLabels.Position);
}

[Test]
Expand Down Expand Up @@ -279,7 +279,7 @@ public void DateTimeValues()

// Define Y-axis properties for decimal values.
ChartAxis yAxis = chart.AxisY;
yAxis.TickLabelPosition = AxisTickLabelPosition.High;
yAxis.TickLabels.Position = AxisTickLabelPosition.High;
yAxis.MajorUnit = 100.0d;
yAxis.MinorUnit = 50.0d;
yAxis.DisplayUnit.Unit = AxisBuiltInUnit.Hundreds;
Expand All @@ -304,7 +304,7 @@ public void DateTimeValues()
Assert.AreEqual(true, chart.AxisX.HasMajorGridlines);
Assert.AreEqual(true, chart.AxisX.HasMinorGridlines);

Assert.AreEqual(AxisTickLabelPosition.High, chart.AxisY.TickLabelPosition);
Assert.AreEqual(AxisTickLabelPosition.High, chart.AxisY.TickLabels.Position);
Assert.AreEqual(100.0d, chart.AxisY.MajorUnit);
Assert.AreEqual(50.0d, chart.AxisY.MinorUnit);
Assert.AreEqual(AxisBuiltInUnit.Hundreds, chart.AxisY.DisplayUnit.Unit);
Expand Down Expand Up @@ -1121,9 +1121,9 @@ public void AxisDisplayUnit()
// Set the X-axis bounds so that the X-axis spans 5 major tick marks and 12 minor tick marks.
axis.Scaling.Minimum = new AxisBound(-10);
axis.Scaling.Maximum = new AxisBound(30);
axis.TickLabelAlignment = ParagraphAlignment.Right;
axis.TickLabels.Alignment = ParagraphAlignment.Right;

Assert.AreEqual(1, axis.TickLabelSpacing);
Assert.AreEqual(1, axis.TickLabels.Spacing);

// Set the tick labels to display their value in millions.
axis.DisplayUnit.Unit = AxisBuiltInUnit.Millions;
Expand All @@ -1149,8 +1149,8 @@ public void AxisDisplayUnit()
Assert.AreEqual(10.0d, axis.MajorUnit);
Assert.AreEqual(-10.0d, axis.Scaling.Minimum.Value);
Assert.AreEqual(30.0d, axis.Scaling.Maximum.Value);
Assert.AreEqual(1, axis.TickLabelSpacing);
Assert.AreEqual(ParagraphAlignment.Right, axis.TickLabelAlignment);
Assert.AreEqual(1, axis.TickLabels.Spacing);
Assert.AreEqual(ParagraphAlignment.Right, axis.TickLabels.Alignment);
Assert.AreEqual(AxisBuiltInUnit.Custom, axis.DisplayUnit.Unit);
Assert.AreEqual(1000000.0d, axis.DisplayUnit.CustomUnit);

Expand Down Expand Up @@ -1641,7 +1641,7 @@ public void DataTable()

Shape shape = builder.InsertChart(ChartType.Column, 432, 252);
Chart chart = shape.Chart;

ChartSeriesCollection series = chart.Series;
series.Clear();
double[] xValues = new double[] { 2020, 2021, 2022, 2023 };
Expand Down
69 changes: 69 additions & 0 deletions Examples/ApiExamples/ApiExamples/ExDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3010,5 +3010,74 @@ public void InsertDocumentInline()
Assert.AreEqual("Before [src content] after", dstDoc.Document.GetText().TrimEnd());
//ExEnd:InsertDocumentInline
}

[TestCase(SaveFormat.Doc)]
[TestCase(SaveFormat.Dot)]
[TestCase(SaveFormat.Docx)]
[TestCase(SaveFormat.Docm)]
[TestCase(SaveFormat.Dotx)]
[TestCase(SaveFormat.Dotm)]
[TestCase(SaveFormat.FlatOpc)]
[TestCase(SaveFormat.FlatOpcMacroEnabled)]
[TestCase(SaveFormat.FlatOpcTemplate)]
[TestCase(SaveFormat.FlatOpcTemplateMacroEnabled)]
[TestCase(SaveFormat.Rtf)]
[TestCase(SaveFormat.WordML)]
[TestCase(SaveFormat.Pdf)]
[TestCase(SaveFormat.Xps)]
[TestCase(SaveFormat.XamlFixed)]
[TestCase(SaveFormat.Svg)]
[TestCase(SaveFormat.HtmlFixed)]
[TestCase(SaveFormat.OpenXps)]
[TestCase(SaveFormat.Ps)]
[TestCase(SaveFormat.Pcl)]
[TestCase(SaveFormat.Html)]
[TestCase(SaveFormat.Mhtml)]
[TestCase(SaveFormat.Epub)]
[TestCase(SaveFormat.Azw3)]
[TestCase(SaveFormat.Mobi)]
[TestCase(SaveFormat.Odt)]
[TestCase(SaveFormat.Ott)]
[TestCase(SaveFormat.Text)]
[TestCase(SaveFormat.XamlFlow)]
[TestCase(SaveFormat.XamlFlowPack)]
[TestCase(SaveFormat.Markdown)]
[TestCase(SaveFormat.Xlsx)]
[TestCase(SaveFormat.Tiff)]
[TestCase(SaveFormat.Png)]
[TestCase(SaveFormat.Bmp)]
[TestCase(SaveFormat.Emf)]
[TestCase(SaveFormat.Jpeg)]
[TestCase(SaveFormat.Gif)]
[TestCase(SaveFormat.Eps)]
public void SaveDocumentToStream(SaveFormat saveFormat)
{
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Writeln("Lorem ipsum");

using (Stream stream = new MemoryStream())
{
if (saveFormat == SaveFormat.HtmlFixed)
{
HtmlFixedSaveOptions saveOptions = new HtmlFixedSaveOptions();
saveOptions.ExportEmbeddedCss = true;
saveOptions.ExportEmbeddedFonts = true;
saveOptions.SaveFormat = saveFormat;

doc.Save(stream, saveOptions);
}
else if (saveFormat == SaveFormat.XamlFixed)
{
XamlFixedSaveOptions saveOptions = new XamlFixedSaveOptions();
saveOptions.ResourcesFolder = ArtifactsDir;
saveOptions.SaveFormat = saveFormat;

doc.Save(stream, saveOptions);
}
else
doc.Save(stream, saveFormat);
}
}
}
}
Loading

0 comments on commit 449afb5

Please sign in to comment.