210 lines
5.8 KiB
C#
210 lines
5.8 KiB
C#
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")]
|
||
[TestCase("Тройник, 40 - 20 - 40")]
|
||
[TestCase("Тройник, 50 - 32 - 50")]
|
||
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("Тройник 50/50/45°")]
|
||
[TestCase("Тройник 50 50 45")]
|
||
public void WastePipeBranchTest(string name)
|
||
{
|
||
Product p = new()
|
||
{
|
||
Name = name
|
||
};
|
||
var prediction = _predEngine.Predict(p);
|
||
Assert.That(prediction.Type, Is.EqualTo("Тройник RAUPIANO"));
|
||
}
|
||
|
||
[TestCase("Муфта соединительная равнопроходная 16 PX")]
|
||
[TestCase("Муфта соединительная переходная 25-16")]
|
||
[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("Переходник с наружн. резьбой 20 1/2")]
|
||
[TestCase("Переходник 16 1/2 НР")]
|
||
[TestCase("ПНР 16")]
|
||
[TestCase("Переход НР 16 1/2")]
|
||
[TestCase("Муфта НР 16 1/2")]
|
||
[TestCase("Соединение прямое с ниппелем")]
|
||
public void AdapterExternalTest(string name)
|
||
{
|
||
Product p = new()
|
||
{
|
||
Name = name
|
||
};
|
||
var prediction = _predEngine.Predict(p);
|
||
Assert.That(prediction.Type, Is.EqualTo("Переходник на наружную резьбу"));
|
||
}
|
||
|
||
[TestCase("Переходник с внутренней резьбой 20-Rp 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("Переходник на внутреннюю резьбу"));
|
||
}
|
||
|
||
[TestCase("Переходник с накидной гайкой 16-G 1/2 RX+")]
|
||
[TestCase("Переходник с накидн. гайкой 16 1/2")]
|
||
[TestCase("Переходник 16 1/2 НГ")]
|
||
[TestCase("ПНГ 16")]
|
||
[TestCase("Переход НГ 16 1/2")]
|
||
[TestCase("Муфта НГ 16 1/2")]
|
||
[TestCase("штуцер с накидной гайкой")]
|
||
public void AdapterScrewcapTest(string name)
|
||
{
|
||
Product p = new()
|
||
{
|
||
Name = name
|
||
};
|
||
var prediction = _predEngine.Predict(p);
|
||
Assert.That(prediction.Type, Is.EqualTo("Переходник с накидной гайкой"));
|
||
}
|
||
|
||
[TestCase("Угольник 16")]
|
||
[TestCase("Угольник 16 90")]
|
||
[TestCase("Угольник 50 45")]
|
||
public void ElbowTest(string name)
|
||
{
|
||
Product p = new()
|
||
{
|
||
Name = name
|
||
};
|
||
var prediction = _predEngine.Predict(p);
|
||
Assert.That(prediction.Type, Is.EqualTo("Угольник RAUTITAN"));
|
||
}
|
||
|
||
[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"));
|
||
}
|
||
|
||
[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"));
|
||
}
|
||
|
||
[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"));
|
||
}
|
||
|
||
[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"));
|
||
}
|
||
|
||
[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("Желоб"));
|
||
}
|
||
|
||
[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"));
|
||
}
|
||
} |