0
0

Return flex result for stabil pipe over 40 diameter
All checks were successful
Test and release / test (push) Successful in 2m39s
Test and release / release-image (push) Successful in 4m26s

This commit is contained in:
Serghei Cebotari 2024-02-16 14:18:49 +03:00
parent f1a7172d42
commit d4a9149daa
3 changed files with 33 additions and 2 deletions

View File

@ -3,7 +3,7 @@ namespace RhSolutions.Api.Tests;
public class RautitanPipesTests : ProductParsersTests
{
[TestCase("Унив.труба RAUTITAN flex 16x2,2, бухта 100м", "Труба РЕХАУ FLEX 16x2,2 бухта")]
[TestCase("Унив.труба RAUTITAN flex 16x2,2, бухта 100м", "Труба РЕХАУ FLEX 16x2,2 бухта")]
[TestCase("Труба flex 16", "Труба РЕХАУ FLEX 16x2,2 бухта")]
[TestCase("Унив.труба RAUTITAN flex 32x4,4, прям.отрезки 6м", "Труба РЕХАУ FLEX 32x4,4 прям.отрезки")]
[TestCase("Труба flex 32", "Труба РЕХАУ FLEX 32x4,4 прям.отрезки")]
@ -21,6 +21,7 @@ public class RautitanPipesTests : ProductParsersTests
[TestCase("труба stabil 16", "Труба Stabil -PLATINUM 16,2х2,6 бухта")]
[TestCase("Универсальн.труба RAUTITAN stabil 32х4,7 мм, прям.отрезки 5м", "Труба Stabil -PLATINUM 32х4,7 прям.отрезки")]
[TestCase("труба stabil 32", "Труба Stabil -PLATINUM 32х4,7 прям.отрезки")]
[TestCase("труба 50", "Труба РЕХАУ FLEX 50x6,9 прям.отрезки")]
public void StabilPipeTest(string query, string modified)
=> Invoke(productType: "Stabil", query, modified);

View File

@ -28,7 +28,7 @@ public abstract class DrinkingWaterHeatingPipe : IProductParser
["отр"] = "прям.отрезки"
};
public bool TryParse(string input, out string output)
public virtual bool TryParse(string input, out string output)
{
output = string.Empty;
var diameterMatch = _diameter.Match(input);

View File

@ -14,4 +14,34 @@ public class StabilPipe : DrinkingWaterHeatingPipe
[50] = "50x6,9",
[63] = "63x8,6"
};
public override bool TryParse(string input, out string output)
{
output = string.Empty;
var diameterMatch = _diameter.Match(input);
if (!diameterMatch.Success)
{
return false;
}
var diameter = int.Parse(diameterMatch.Groups["Diameter"].Value);
var typeMatch = _type.Match(input);
if (diameter > 40)
{
var flexParser = new FlexPipe();
return flexParser.TryParse(input, out output);
}
if (typeMatch.Success)
{
var type = typeMatch.Groups["Type"].Value;
output = $"Труба {_title} {_diameterNames[diameter]} {_makeUp[type]}";
}
else if (diameter < 32)
{
output = $"Труба {_title} {_diameterNames[diameter]} {_makeUp["бухт"]}";
}
else
{
output = $"Труба {_title} {_diameterNames[diameter]} {_makeUp["отр"]}";
}
return true;
}
}