Remove tests
This commit is contained in:
parent
e0931c2e5f
commit
f27bf369cf
@ -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();
|
||||
}
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
namespace RhSolutions.ML.Tests;
|
||||
|
||||
public class KanDataset : DatasetBase
|
||||
{
|
||||
protected override string FileName => "KAN";
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
namespace RhSolutions.ML.Tests;
|
||||
|
||||
public class MiscDataset : DatasetBase
|
||||
{
|
||||
protected override string FileName => "Misc";
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
namespace RhSolutions.ML.Tests;
|
||||
|
||||
public class PradoDataset : DatasetBase
|
||||
{
|
||||
protected override string FileName => "Prado";
|
||||
}
|
@ -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);
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
namespace RhSolutions.ML.Tests;
|
||||
|
||||
public class SanextDataset : DatasetBase
|
||||
{
|
||||
protected override string FileName => "Sanext";
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
namespace RhSolutions.ML.Tests;
|
||||
|
||||
public class TeceDataset : DatasetBase
|
||||
{
|
||||
protected override string FileName => "Tece";
|
||||
}
|
@ -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));
|
||||
}
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
namespace RhSolutions.ML.Tests;
|
||||
|
||||
public class UponorDataset : DatasetBase
|
||||
{
|
||||
protected override string FileName => "Uponor";
|
||||
}
|
Loading…
Reference in New Issue
Block a user