From ba91d634614145a72aefd11d60c32ec628a83757 Mon Sep 17 00:00:00 2001 From: Akhan Zhakiyanov Date: Fri, 13 Sep 2024 22:37:28 +0800 Subject: [PATCH] feat: add tests project (#7) --- src/AEMO.MDFF.Tests/AEMO.MDFF.Tests.csproj | 33 ++++++++++++++++++++++ src/AEMO.MDFF.Tests/NEM12/BasicTest.cs | 33 ++++++++++++++++++++++ src/AEMO.MDFF.Tests/nem12-sample.csv | 14 +++++++++ src/AEMO.MDFF.sln | 6 ++++ 4 files changed, 86 insertions(+) create mode 100644 src/AEMO.MDFF.Tests/AEMO.MDFF.Tests.csproj create mode 100644 src/AEMO.MDFF.Tests/NEM12/BasicTest.cs create mode 100644 src/AEMO.MDFF.Tests/nem12-sample.csv diff --git a/src/AEMO.MDFF.Tests/AEMO.MDFF.Tests.csproj b/src/AEMO.MDFF.Tests/AEMO.MDFF.Tests.csproj new file mode 100644 index 0000000..480e197 --- /dev/null +++ b/src/AEMO.MDFF.Tests/AEMO.MDFF.Tests.csproj @@ -0,0 +1,33 @@ + + + + net8.0 + enable + enable + + false + true + + + + + + + + + + + + + + + + PreserveNewest + + + + + + + + diff --git a/src/AEMO.MDFF.Tests/NEM12/BasicTest.cs b/src/AEMO.MDFF.Tests/NEM12/BasicTest.cs new file mode 100644 index 0000000..b0a28fd --- /dev/null +++ b/src/AEMO.MDFF.Tests/NEM12/BasicTest.cs @@ -0,0 +1,33 @@ +using AEMO.MDFF.NEM12; +using Xunit.Abstractions; + +namespace AEMO.MDFF.Tests.NEM12; + +public class BasicTest +{ + private readonly ITestOutputHelper _testOutputHelper; + + public BasicTest(ITestOutputHelper testOutputHelper) + { + _testOutputHelper = testOutputHelper; + } + + [Fact] + public async Task Test1() + { + var nem12Reader = new Nem12Reader(); + await using var fs = new FileStream("nem12-sample.csv", FileMode.Open, FileAccess.Read); + await foreach (var r in nem12Reader.ReadAsync(fs, CancellationToken.None)) + { + switch (r) + { + case HeaderRecord { RecordIndicator: var vh }: + Assert.Equal(100.ToString(), vh); + break; + case NMIDataDetailsRecord { NextScheduledReadDate: var nsrd }: + _testOutputHelper.WriteLine(nsrd.ToLongDateString()); + break; + } + } + } +} diff --git a/src/AEMO.MDFF.Tests/nem12-sample.csv b/src/AEMO.MDFF.Tests/nem12-sample.csv new file mode 100644 index 0000000..c5adc9f --- /dev/null +++ b/src/AEMO.MDFF.Tests/nem12-sample.csv @@ -0,0 +1,14 @@ +100,NEM12,200506081149,UNITEDDP,NEMMCO +200,NEM1201009,E1E2,1,E1,N1,01009,kWh,30,20050610 +300,20050301,0,0,0,0,0,0,0,0,0,0,0,0,0.461,0.810,0.568,1.234,1.353,1.507,1.344,1.773,0.848,1.271,0.895,1.327,1.013,1.793,0.988,0.985,0.876,0.555,0.760,0.938,0.566,0.512,0.970,0.760,0.731,0.615,0.886,0.531,0.774,0.712,0.598,0.670,0.587,0.657,0.345,0.231,A,,,20050310121004,20050310182204 +300,20050302,0,0,0,0,0,0,0,0,0,0,0,0,0.235,0.567,0.890,1.123,1.345,1.567,1.543,1.234,0.987,1.123,0.876,1.345,1.145,1.173,1.265,0.987,0.678,0.998,0.768,0.954,0.876,0.845,0.932,0.786,0.999,0.879,0.777,0.578,0.709,0.772,0.625,0.653,0.543,0.599,0.432,0.432,A,,,20050310121004,20050310182204 +300,20050303,0,0,0,0,0,0,0,0,0,0,0,0,0.261,0.310,0.678,0.934,1.211,1.134,1.423,1.370,0.988,1.207,0.890,1.320,1.130,1.913,1.180,0.950,0.746,0.635,0.956,0.887,0.560,0.700,0.788,0.668,0.543,0.738,0.802,0.490,0.598,0.809,0.520,0.670,0.570,0.600,0.289,0.321,A,,,20050310121004,20050310182204 +300,20050304,0,0,0,0,0,0,0,0,0,0,0,0,0.335,0.667,0.790,1.023,1.145,1.777,1.563,1.344,1.087,1.453,0.996,1.125,1.435,1.263,1.085,1.487,1.278,0.768,0.878,0.754,0.476,1.045,1.132,0.896,0.879,0.679,0.887,0.784,0.954,0.712,0.599,0.593,0.674,0.799,0.232,0.612,A,,,20050310121004,20050310182204 +500,O,S01009,20050310121004, +200,NEM1201010,E1E2,2,E2,,01009,kWh,30,20050610 +300,20050301,0,0,0,0,0,0,0,0,0,0,0,0,0.154,0.460,0.770,1.003,1.059,1.750,1.423,1.200,0.980,1.111,0.800,1.403,1.145,1.173,1.065,1.187,0.900,0.998,0.768,1.432,0.899,1.211,0.873,0.786,1.504,0.719,0.817,0.780,0.709,0.700,0.565,0.655,0.543,0.786,0.430,0.432,A,,,20050310121004, +300,20050302,0,0,0,0,0,0,0,0,0,0,0,0,0.461,0.810,0.776,1.004,1.034,1.200,1.310,1.342,0.998,1.311,1.095,1.320,1.115,1.436,0.890,1.255,0.916,0.955,0.711,0.780,0.606,0.510,0.905,0.660,0.835,0.798,0.965,1.122,1.004,0.772,0.508,0.670,0.670,0.432,0.415,0.220,A,,,20050310121004, +300,20050303,0,0,0,0,0,0,0,0,0,0,0,0,0.335,0.667,0.790,1.023,1.145,1.777,1.563,1.344,1.087,1.453,0.996,1.125,1.435,1.263,1.085,1.487,1.278,0.768,0.878,0.754,0.476,1.045,1.132,0.896,0.879,0.679,0.887,0.784,0.954,0.712,0.599,0.593,0.674,0.799,0.232,0.610,A,,,20050310121004, +300,20050304,0,0,0,0,0,0,0,0,0,0,0,0,0.461,0.415,0.778,0.940,1.191,1.345,1.390,1.222,1.134,1.207,0.877,1.655,1.099,1.625,1.010,0.950,1.255,0.635,0.956,0.880,0.660,0.810,0.878,0.778,0.643,0.838,0.812,0.490,0.598,0.811,0.572,0.417,0.707,0.670,0.290,0.355,A,,,20050310121004, +500,O,S01009,20050310121004, +900 diff --git a/src/AEMO.MDFF.sln b/src/AEMO.MDFF.sln index aeaa534..066b554 100644 --- a/src/AEMO.MDFF.sln +++ b/src/AEMO.MDFF.sln @@ -2,6 +2,8 @@ Microsoft Visual Studio Solution File, Format Version 12.00 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AEMO.MDFF", "AEMO.MDFF\AEMO.MDFF.csproj", "{8266E4B7-A41E-4212-9E0F-1E1F4330C40B}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AEMO.MDFF.Tests", "AEMO.MDFF.Tests\AEMO.MDFF.Tests.csproj", "{5BA10E42-8C5B-49DF-9701-08DC50374F8A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -12,5 +14,9 @@ Global {8266E4B7-A41E-4212-9E0F-1E1F4330C40B}.Debug|Any CPU.Build.0 = Debug|Any CPU {8266E4B7-A41E-4212-9E0F-1E1F4330C40B}.Release|Any CPU.ActiveCfg = Release|Any CPU {8266E4B7-A41E-4212-9E0F-1E1F4330C40B}.Release|Any CPU.Build.0 = Release|Any CPU + {5BA10E42-8C5B-49DF-9701-08DC50374F8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5BA10E42-8C5B-49DF-9701-08DC50374F8A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5BA10E42-8C5B-49DF-9701-08DC50374F8A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5BA10E42-8C5B-49DF-9701-08DC50374F8A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal