From 0c85e000b401c1bab36d07b82c4a0b727562c42a Mon Sep 17 00:00:00 2001 From: Serghei Cebotari Date: Wed, 20 Sep 2023 08:18:22 +0300 Subject: Initial commit --- RhSolutions.ML.Tests/RhSolutions.ML.Tests.csproj | 25 ++++++++++ RhSolutions.ML.Tests/Tests.cs | 59 ++++++++++++++++++++++++ RhSolutions.ML.Tests/Usings.cs | 2 + 3 files changed, 86 insertions(+) create mode 100644 RhSolutions.ML.Tests/RhSolutions.ML.Tests.csproj create mode 100644 RhSolutions.ML.Tests/Tests.cs create mode 100644 RhSolutions.ML.Tests/Usings.cs (limited to 'RhSolutions.ML.Tests') diff --git a/RhSolutions.ML.Tests/RhSolutions.ML.Tests.csproj b/RhSolutions.ML.Tests/RhSolutions.ML.Tests.csproj new file mode 100644 index 0000000..697d9a0 --- /dev/null +++ b/RhSolutions.ML.Tests/RhSolutions.ML.Tests.csproj @@ -0,0 +1,25 @@ + + + + net7.0 + enable + enable + + false + true + + + + + + + + + + + + + + + + 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 _predEngine; + + [SetUp] + public void Setup() + { + _mlContext = new MLContext(seed: 0); + ITransformer loadedNodel = _mlContext.Model.Load(_dataPath, out var _); + _predEngine = _mlContext.Model.CreatePredictionEngine(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 diff --git a/RhSolutions.ML.Tests/Usings.cs b/RhSolutions.ML.Tests/Usings.cs new file mode 100644 index 0000000..38d77d5 --- /dev/null +++ b/RhSolutions.ML.Tests/Usings.cs @@ -0,0 +1,2 @@ +global using NUnit.Framework; +global using Microsoft.ML; \ No newline at end of file -- cgit v1.2.3