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

176 lines
4.7 KiB
C#
Raw Normal View History

2023-09-20 08:18:22 +03:00
namespace RhSolutions.ML.Tests;
public class Tests
{
private static string _appPath = Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]) ?? ".";
2023-09-20 13:46:55 +03:00
private static string _dataPath = Path.Combine(_appPath, "..", "..", "..", "..", "Models", "model.zip");
2023-09-20 08:18:22 +03:00
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")]
2023-09-20 14:17:50 +03:00
[TestCase("Тройник 50/50/45°")]
public void WastePipeBranchTest(string name)
2023-09-20 08:18:22 +03:00
{
Product p = new()
{
Name = name
};
var prediction = _predEngine.Predict(p);
Assert.That(prediction.Type, Is.EqualTo("Тройник RAUPIANO"));
}
2023-09-20 13:46:55 +03:00
[TestCase("Муфта соединительная равнопроходная 16 PX")]
2023-09-20 16:18:38 +03:00
[TestCase("Муфта соединительная переходная 25-16")]
2023-09-20 13:46:55 +03:00
[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+")]
2023-09-20 16:18:38 +03:00
[TestCase("Переходник с наружн. резьбой 20 1/2")]
2023-09-20 13:46:55 +03:00
[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("Переходник на наружную резьбу"));
2023-09-20 16:18:38 +03:00
}
[TestCase("Переходник с внутренней резьбой 20-R 3/4 RX+")]
[TestCase("Переходник с внутр. резьбой 20 1/2")]
[TestCase("Переходник 16 1/2 ВР")]
[TestCase("ПВР 16")]
[TestCase("Переход ВР 16 1/2")]
[TestCase("Муфта ВР 16 1/2")]
public void AdapterInternalTest(string name)
{
Product p = new()
{
Name = name
};
var prediction = _predEngine.Predict(p);
Assert.That(prediction.Type, Is.EqualTo("Переходник на внутреннюю резьбу"));
2023-09-20 13:46:55 +03:00
}
2023-09-20 14:32:33 +03:00
[TestCase("Труба stabil 16")]
[TestCase("Труба stabil")]
public void StabilPipeTest(string name)
{
Product p = new()
{
Name = name
};
var prediction = _predEngine.Predict(p);
Assert.That(prediction.Type, Is.EqualTo("Stabil"));
}
2023-09-20 14:35:57 +03:00
[TestCase("Труба flex 16")]
[TestCase("Труба flex")]
public void FlexPipeTest(string name)
{
Product p = new()
{
Name = name
};
var prediction = _predEngine.Predict(p);
Assert.That(prediction.Type, Is.EqualTo("Flex"));
}
2023-09-20 14:41:16 +03:00
[TestCase("Труба pink 16")]
[TestCase("Труба pink")]
public void PinkPipeTest(string name)
{
Product p = new()
{
Name = name
};
var prediction = _predEngine.Predict(p);
Assert.That(prediction.Type, Is.EqualTo("Pink"));
2023-09-20 14:47:43 +03:00
}
2023-09-20 14:51:18 +03:00
[TestCase("Труба black 16")]
[TestCase("Труба black")]
public void BlackPipeTest(string name)
{
Product p = new()
{
Name = name
};
var prediction = _predEngine.Predict(p);
Assert.That(prediction.Type, Is.EqualTo("Black"));
}
2023-09-20 16:22:55 +03:00
[TestCase("Фиксирующий желоб 16")]
[TestCase("Желоб 16")]
public void SupportingClipTest(string name)
{
Product p = new()
{
Name = name
};
var prediction = _predEngine.Predict(p);
Assert.That(prediction.Type, Is.EqualTo("Желоб"));
}
2023-09-20 14:47:43 +03:00
[TestCase("Труба канализационная")]
[TestCase("Труба 110")]
[TestCase("Труба 110 500")]
public void WastePipeTest(string name)
{
Product p = new()
{
Name = name
};
var prediction = _predEngine.Predict(p);
Assert.That(prediction.Type, Is.EqualTo("Труба RAUPIANO"));
2023-09-20 14:41:16 +03:00
}
2023-09-20 08:18:22 +03:00
}