summaryrefslogtreecommitdiff
path: root/RhSolutions.ML.Tests
diff options
context:
space:
mode:
authorSerghei Cebotari <serghei@cebotari.ru>2023-09-20 08:18:22 +0300
committerSerghei Cebotari <serghei@cebotari.ru>2023-09-20 08:18:22 +0300
commit0c85e000b401c1bab36d07b82c4a0b727562c42a (patch)
tree86ed7e6dd9b27f6e21603a60e4006a57dd20f04b /RhSolutions.ML.Tests
Initial commit
Diffstat (limited to 'RhSolutions.ML.Tests')
-rw-r--r--RhSolutions.ML.Tests/RhSolutions.ML.Tests.csproj25
-rw-r--r--RhSolutions.ML.Tests/Tests.cs59
-rw-r--r--RhSolutions.ML.Tests/Usings.cs2
3 files changed, 86 insertions, 0 deletions
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 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <TargetFramework>net7.0</TargetFramework>
+ <ImplicitUsings>enable</ImplicitUsings>
+ <Nullable>enable</Nullable>
+
+ <IsPackable>false</IsPackable>
+ <IsTestProject>true</IsTestProject>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <PackageReference Include="Microsoft.ML" Version="2.0.1" />
+ <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
+ <PackageReference Include="NUnit" Version="3.13.3" />
+ <PackageReference Include="NUnit3TestAdapter" Version="4.4.2" />
+ <PackageReference Include="NUnit.Analyzers" Version="3.6.1" />
+ <PackageReference Include="coverlet.collector" Version="3.2.0" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="..\RhSolutions.ML.Builder\RhSolutions.ML.Builder.csproj" />
+ </ItemGroup>
+
+</Project>
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
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