49 lines
1.2 KiB
C#
49 lines
1.2 KiB
C#
using MeetTheTeacher.Export;
|
|
|
|
namespace MeetTheTeacher.Test.Export;
|
|
|
|
public sealed class HtmlDataExporterTests : ExporterTestBase, IDisposable
|
|
{
|
|
private readonly HtmlDataExporter _htmlDataExporter;
|
|
|
|
public HtmlDataExporterTests()
|
|
{
|
|
_htmlDataExporter = new HtmlDataExporter();
|
|
}
|
|
|
|
protected override string FileExtension => "html";
|
|
|
|
public void Dispose()
|
|
{
|
|
// Clean up the test file.
|
|
if (File.Exists(FilePath))
|
|
{
|
|
File.Delete(FilePath);
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void Export()
|
|
{
|
|
_htmlDataExporter.Export(SampleData, FileName);
|
|
|
|
File.Exists(FilePath).Should().BeTrue();
|
|
|
|
string[]? rows = File.ReadAllLines(FilePath);
|
|
|
|
void Check(int rowIdx, string expected)
|
|
{
|
|
rows[rowIdx].Trim().Should().Be(expected);
|
|
}
|
|
|
|
Check(0, "<table>");
|
|
Check(1, "<thead>");
|
|
Check(2, "<tr><th>Name</th><th>Age</th></tr>");
|
|
Check(3, "</thead>");
|
|
Check(4, "<tbody>");
|
|
Check(5, "<tr><td>John</td><td>30</td></tr>");
|
|
Check(6, "<tr><td>Jane</td><td>25</td></tr>");
|
|
Check(7, "</tbody>");
|
|
Check(8, "</table>");
|
|
}
|
|
}
|