0
0
RhSolutions-ML/RhSolutions.ML.Tests/Tests.cs

85 lines
2.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

namespace RhSolutions.ML.Tests;
public class Tests
{
private static string _appPath = Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]) ?? ".";
private static string _dataPath = Path.Combine(_appPath, "..", "..", "..", "..", "Models", "model.zip");
private MLContext _mlContext;
private PredictionEngine<Product, TypePrediction> _predEngine;
[SetUp]
public void Setup()
{
_mlContext = new MLContext(seed: 0);
ITransformer loadedNodel = _mlContext.Model.Load(_dataPath, out var _);
_predEngine = _mlContext.Model.CreatePredictionEngine<Product, TypePrediction>(loadedNodel);
}
[TestCase("Гильза 16")]
[TestCase("Пресс-втулка")]
public void SleevesTest(string name)
{
Product p = new()
{
Name = name
};
var prediction = _predEngine.Predict(p);
Assert.That(prediction.Type, Is.EqualTo("Монтажная гильза"));
}
[TestCase("Тройник 20")]
[TestCase("Тройник 20-16-16")]
[TestCase("Тройник 20х20х20")]
[TestCase("Тройник 32*32*32")]
[TestCase("Тройник 50-50-32")]
public void TPieceTest(string name)
{
Product p = new()
{
Name = name
};
var prediction = _predEngine.Predict(p);
Assert.That(prediction.Type, Is.EqualTo("Тройник RAUTITAN"));
}
[TestCase("Тройник 50/50/45")]
[TestCase("Тройник 50/50/45°")]
public void WastePipeBranchTest(string name)
{
Product p = new()
{
Name = name
};
var prediction = _predEngine.Predict(p);
Assert.That(prediction.Type, Is.EqualTo("Тройник RAUPIANO"));
}
[TestCase("Муфта соединительная равнопроходная 16 PX")]
[TestCase("Муфта 16")]
[TestCase("Переход 20-16")]
[TestCase("Переходник 20-16")]
public void CouplingTest(string name)
{
Product p = new()
{
Name = name
};
var prediction = _predEngine.Predict(p);
Assert.That(prediction.Type, Is.EqualTo("Муфта соединительная"));
}
[TestCase("Переходник с наружной резьбой 20-R 3/4 RX+")]
[TestCase("Переходник 16 1/2 НР")]
[TestCase("ПНР 16")]
[TestCase("Переход НР 16 1/2")]
[TestCase("Муфта НР 16 1/2")]
public void AdapterExternalTest(string name)
{
Product p = new()
{
Name = name
};
var prediction = _predEngine.Predict(p);
Assert.That(prediction.Type, Is.EqualTo("Переходник на наружную резьбу"));
}
}