using System.Diagnostics.CodeAnalysis; namespace Tests; [ExcludeFromCodeCoverage] public sealed class Tests { [Test] public void TestBasicImplementation() { var testData = new TestDataRecordStructMixed("Area1", 1, 1.1f, 7); Assert.Multiple(() => { Assert.That(typeof(TestDataRecordStructMixed).GetInterface("IConvertToCSV"), Is.Not.Null); Assert.That(typeof(TestDataRecordStructMixed).GetProperties(), Has.Length.EqualTo(5)); var numberColumns = testData.GetCSVColumnCount(); Assert.That(numberColumns, Is.EqualTo(5)); var header = testData.GetCSVHeaders(); Assert.That(header, Is.EquivalentTo(new[] { "Area", "Step", "Value", "Z", "State" })); var dataLine = testData.ConvertToCSVDataLine(); Assert.That(dataLine, Is.EquivalentTo(new[] { "Area1", "1", "1.1", "7", "False" })); }); } [Test] public void TestLongText() { var text = """ This is a long text that should be split into multiple lines and should be able to be used as a multiline string ... and on and on... """; var testData = new TestDataRecordStructMixed(text, 500_000, 0.00057f, -6_087); Assert.Multiple(() => { var dataLine = testData.ConvertToCSVDataLine(); Assert.That(dataLine, Is.EquivalentTo(new[] { text, "500000", "0.00057", "-6087", "False" })); }); } [Test] public void TestOneLineStructure() { var testData = new TestDataOneLine("Bob", 120); Assert.Multiple(() => { var numberColumns = testData.GetCSVColumnCount(); Assert.That(numberColumns, Is.EqualTo(2)); var header = testData.GetCSVHeaders(); Assert.That(header, Is.EquivalentTo(new[] { "Name", "Age" })); var dataLine = testData.ConvertToCSVDataLine(); Assert.That(dataLine, Is.EquivalentTo(new[] { "Bob", "120" })); }); } [Test] public void TestRegularStruct() { var testData = new TestDataRegularStruct { City = "New York", Age = 35, Size = 1.85, }; Assert.Multiple(() => { var numberColumns = testData.GetCSVColumnCount(); Assert.That(numberColumns, Is.EqualTo(3)); var header = testData.GetCSVHeaders(); Assert.That(header, Is.EquivalentTo(new[] { "City", "Age", "Size" })); var dataLine = testData.ConvertToCSVDataLine(); Assert.That(dataLine, Is.EquivalentTo(new[] { "New York", "35", "1.85" })); }); } }