0
0

Add default adapter threads
All checks were successful
Test and release / test (push) Successful in 4m9s
Test and release / release-image (push) Successful in 4m23s

This commit is contained in:
Serghei Cebotari 2024-02-19 22:13:08 +03:00
parent 6611bf2e26
commit 11e0fd8dfd
2 changed files with 18 additions and 2 deletions

View File

@ -34,6 +34,7 @@ public class RautitanFittingsTests : ProductParsersTests
=> Invoke(productType: "Муфта соединительная", query, modified);
[TestCase("Переходник с внутренней резьбой 16xG 3/4\" для труб из сшитого полиэтилена аксиальный", "Переходник с внутренней резьбой -угольник-переходник 16 3/4")]
[TestCase("Переходник на внутреннюю резьбу 20", "Переходник с внутренней резьбой -угольник-переходник 20 1/2")]
public void AdapterInternalTest(string query, string modified)
=> Invoke(productType: "Переходник на внутреннюю резьбу", query, modified);

View File

@ -4,6 +4,16 @@ namespace RhSolutions.Parsers.Fittings;
public abstract class Adapter : DrinkingWaterHeatingFitting
{
protected Dictionary<string, string> _defaultThreads = new()
{
["16"] = "1/2",
["20"] = "1/2",
["25"] = "3/4",
["32"] = "1",
["40"] = "1 1/4",
["50"] = "1 1/2",
["63"] = "2"
};
public override bool TryParse(string input, out string output)
{
output = string.Empty;
@ -13,11 +23,16 @@ public abstract class Adapter : DrinkingWaterHeatingFitting
return false;
}
Match thread = _thread.Match(input);
string threadValue;
if (!thread.Success)
{
return false;
threadValue = _defaultThreads[diameter.Groups["Diameter"].Value];
}
output = $"{_title} {diameter.Groups["Diameter"]} {thread.Groups["Thread"]}";
else
{
threadValue = thread.Groups["Thread"].Value;
}
output = $"{_title} {diameter.Groups["Diameter"]} {threadValue}";
return true;
}
}