summaryrefslogtreecommitdiff
path: root/RhSolutions.ML.Tests/Tests.cs
blob: 0349ddb877e0dbe8af518c12c18bc62b39a35ed8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
namespace RhSolutions.ML.Tests;

public class Tests
{
	private static string _appPath = Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]) ?? ".";
	private static string _dataPath = Path.Combine(_appPath, "..", "..", "..", "..", "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"));		
	}
	
	[TestCase("Муфта соединительная равнопроходная 16 PX")]
	[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+")]
	[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("Переходник на наружную резьбу"));		
	}
}