diff options
author | Serghei Cebotari <serghei@cebotari.ru> | 2023-12-29 11:24:23 +0300 |
---|---|---|
committer | Serghei Cebotari <serghei@cebotari.ru> | 2023-12-29 11:24:23 +0300 |
commit | 7e22efde3f3be8d9f39856eb704d438feae8eb0f (patch) | |
tree | abacfa6f3309b27457ccb35a17cf75659ce4ba40 /RhSolutions.ML.Tests/DatasetBase.cs | |
parent | 3be0df94c032b945af803d5056fb01df7af417f3 (diff) |
Implement Data driven tests
Diffstat (limited to 'RhSolutions.ML.Tests/DatasetBase.cs')
-rw-r--r-- | RhSolutions.ML.Tests/DatasetBase.cs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/RhSolutions.ML.Tests/DatasetBase.cs b/RhSolutions.ML.Tests/DatasetBase.cs new file mode 100644 index 0000000..904bab3 --- /dev/null +++ b/RhSolutions.ML.Tests/DatasetBase.cs @@ -0,0 +1,22 @@ +using System.Collections; + +namespace RhSolutions.ML.Tests; +public abstract class DatasetBase : IEnumerable +{ + protected virtual string FileName {get;set;} = string.Empty; + public IEnumerator GetEnumerator() + { + string path = Path.Combine("..", "..", "..", "TestData", $"{FileName}.csv"); + using FileStream stream = new(path, FileMode.Open, FileAccess.Read); + StreamReader reader = new(stream); + string? inputLine = reader.ReadLine(); + while (inputLine != null) + { + var data = inputLine.Split(';'); + yield return new Product { Name = data[0], Type = data[1] }; + inputLine = reader.ReadLine(); + } + reader.Close(); + stream.Close(); + } +} |