summaryrefslogtreecommitdiff
path: root/RhSolutions.ML.Tests/Tests.cs
diff options
context:
space:
mode:
Diffstat (limited to 'RhSolutions.ML.Tests/Tests.cs')
-rw-r--r--RhSolutions.ML.Tests/Tests.cs59
1 files changed, 59 insertions, 0 deletions
diff --git a/RhSolutions.ML.Tests/Tests.cs b/RhSolutions.ML.Tests/Tests.cs
new file mode 100644
index 0000000..e8203a0
--- /dev/null
+++ b/RhSolutions.ML.Tests/Tests.cs
@@ -0,0 +1,59 @@
+namespace RhSolutions.ML.Tests;
+
+public class Tests
+{
+ private static string _appPath = Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]) ?? ".";
+ private static string _dataPath = Path.Combine(_appPath, "..", "..", "..", ".."
+ ,"RhSolutions.ML.Builder" , "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("Тройник 110 110 45")]
+ [TestCase("Тройник 50 50 87")]
+ [TestCase("Тройник 50 50 45")]
+ public void TPiecePianoTest(string name)
+ {
+ Product p = new()
+ {
+ Name = name
+ };
+ var prediction = _predEngine.Predict(p);
+ Assert.That(prediction.Type, Is.EqualTo("Тройник RAUPIANO"));
+ }
+} \ No newline at end of file