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")); } }