0
0

Remove tests

This commit is contained in:
Serghei Cebotari 2024-01-12 00:03:18 +03:00
parent e0931c2e5f
commit f27bf369cf
16 changed files with 0 additions and 125 deletions

View File

@ -1,22 +0,0 @@
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();
}
}

View File

@ -1,6 +0,0 @@
namespace RhSolutions.ML.Tests;
public class KanDataset : DatasetBase
{
protected override string FileName => "KAN";
}

View File

@ -1,6 +0,0 @@
namespace RhSolutions.ML.Tests;
public class MiscDataset : DatasetBase
{
protected override string FileName => "Misc";
}

View File

@ -1,6 +0,0 @@
namespace RhSolutions.ML.Tests;
public class PradoDataset : DatasetBase
{
protected override string FileName => "Prado";
}

View File

@ -1,31 +0,0 @@
namespace RhSolutions.ML.Tests;
public class RautitanTests : TestBase
{
[TestCaseSource(typeof(RautitanDataset))]
public void RhSolutionsTests(Product expected)
=> Execute(expected);
[TestCaseSource(typeof(SanextDataset))]
public void SanextTests(Product expected)
=> Execute(expected);
[TestCaseSource(typeof(TeceDataset))]
public void TeceTests(Product expected)
=> Execute(expected);
[TestCaseSource(typeof(UponorDataset))]
public void UponorTest(Product expected)
=> Execute(expected);
[TestCaseSource(typeof(PradoDataset))]
public void PradoTests(Product expexted)
=> Execute(expexted);
[TestCaseSource(typeof(KanDataset))]
public void KanTests(Product expected)
=>Execute(expected);
[TestCaseSource(typeof(MiscDataset))]
public void MiscTest(Product expected)
=> Execute(expected);
}

View File

@ -1,6 +0,0 @@
namespace RhSolutions.ML.Tests;
public class SanextDataset : DatasetBase
{
protected override string FileName => "Sanext";
}

View File

@ -1,6 +0,0 @@
namespace RhSolutions.ML.Tests;
public class TeceDataset : DatasetBase
{
protected override string FileName => "Tece";
}

View File

@ -1,36 +0,0 @@
namespace RhSolutions.ML.Tests;
public abstract class TestBase
{
protected static string _appPath = Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]) ?? ".";
protected static string _dataPath = Path.Combine(_appPath, "..", "..", "..", "..", "Models", "model.zip");
protected MLContext _mlContext;
protected PredictionEngine<Product, TypePrediction> _predEngine;
public TestBase()
{
_mlContext = new MLContext(seed: 0);
ITransformer loadedModel = _mlContext.Model.Load(_dataPath, out var _);
_predEngine = _mlContext.Model.CreatePredictionEngine<Product, TypePrediction>(loadedModel);
}
public void Execute(string name, string expectedGroup)
{
Product p = new()
{
Name = name
};
var prediction = _predEngine.Predict(p);
Assert.That(prediction.Type, Is.EqualTo(expectedGroup));
}
public void Execute(Product expected)
{
Product actual = new()
{
Name = expected.Name
};
var prediction = _predEngine.Predict(actual);
Assert.That(prediction.Type, Is.EqualTo(expected.Type));
}
}

View File

@ -1,6 +0,0 @@
namespace RhSolutions.ML.Tests;
public class UponorDataset : DatasetBase
{
protected override string FileName => "Uponor";
}