0
0

Compare commits

..

4 Commits

Author SHA1 Message Date
d4a9149daa 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
2024-02-16 14:18:49 +03:00
f1a7172d42 Switch to "РЕХАУ PINK" 2024-02-16 14:09:55 +03:00
747a80dc41 Switch to "РЕХАУ BLACK" 2024-02-16 14:08:44 +03:00
d7eb095e57 Switch to "РЕХАУ FLEX" 2024-02-16 14:06:46 +03:00
6 changed files with 45 additions and 14 deletions

View File

@ -3,17 +3,17 @@ namespace RhSolutions.Api.Tests;
public class RautitanPipesTests : ProductParsersTests 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("Труба flex 16", "Труба РЕХАУ FLEX 16x2,2 бухта")]
[TestCase("Унив.труба RAUTITAN flex 32x4,4, прям.отрезки 6м", "Труба Flex 32x4,4 прям.отрезки")] [TestCase("Унив.труба RAUTITAN flex 32x4,4, прям.отрезки 6м", "Труба РЕХАУ FLEX 32x4,4 прям.отрезки")]
[TestCase("Труба flex 32", "Труба Flex 32x4,4 прям.отрезки")] [TestCase("Труба flex 32", "Труба РЕХАУ FLEX 32x4,4 прям.отрезки")]
public void FlexPipeTest(string query, string modified) public void FlexPipeTest(string query, string modified)
=> Invoke(productType: "Flex", query, modified); => Invoke(productType: "Flex", query, modified);
[TestCase("Унив. труба RAUTITAN pink+ 16х2,2 мм, бухта 120 м", "Труба Pink+ 16х2,2 бухта")] [TestCase("Унив. труба RAUTITAN pink+ 16х2,2 мм, бухта 120 м", "Труба РЕХАУ PINK 16х2,2 бухта")]
[TestCase("труба pink 16", "Труба Pink+ 16х2,2 бухта")] [TestCase("труба pink 16", "Труба РЕХАУ PINK 16х2,2 бухта")]
[TestCase("Унив. труба RAUTITAN pink+ 32х4,4 мм, бухта 50 м", "Труба Pink+ 32х4,4 бухта")] [TestCase("Унив. труба RAUTITAN pink+ 32х4,4 мм, бухта 50 м", "Труба РЕХАУ PINK 32х4,4 бухта")]
[TestCase("труба pink 32", "Труба Pink+ 32х4,4 прямые отрезки")] [TestCase("труба pink 32", "Труба РЕХАУ PINK 32х4,4 прямые отрезки")]
public void PinkPipeTest(string query, string modified) public void PinkPipeTest(string query, string modified)
=> Invoke(productType: "Pink", query, modified); => Invoke(productType: "Pink", query, modified);
@ -21,11 +21,12 @@ public class RautitanPipesTests : ProductParsersTests
[TestCase("труба stabil 16", "Труба Stabil -PLATINUM 16,2х2,6 бухта")] [TestCase("труба stabil 16", "Труба Stabil -PLATINUM 16,2х2,6 бухта")]
[TestCase("Универсальн.труба RAUTITAN stabil 32х4,7 мм, прям.отрезки 5м", "Труба Stabil -PLATINUM 32х4,7 прям.отрезки")] [TestCase("Универсальн.труба RAUTITAN stabil 32х4,7 мм, прям.отрезки 5м", "Труба Stabil -PLATINUM 32х4,7 прям.отрезки")]
[TestCase("труба stabil 32", "Труба 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) public void StabilPipeTest(string query, string modified)
=> Invoke(productType: "Stabil", query, modified); => Invoke(productType: "Stabil", query, modified);
[TestCase("Отоп.труба РЕХАУ BLACK 16х2,2 мм, бухта 200 м", "Труба Black 16х2,2 бухта")] [TestCase("Отоп.труба РЕХАУ BLACK 16х2,2 мм, бухта 200 м", "Труба РЕХАУ BLACK 16х2,2 бухта")]
[TestCase("труба BLACK 16", "Труба Black 16х2,2 бухта")] [TestCase("труба BLACK 16", "Труба РЕХАУ BLACK 16х2,2 бухта")]
public void BlackPipeTest(string query, string modified) public void BlackPipeTest(string query, string modified)
=> Invoke(productType: "Black", query, modified); => Invoke(productType: "Black", query, modified);
} }

View File

@ -3,7 +3,7 @@ namespace RhSolutions.Parsers.Pipes;
[ParserKey("Black")] [ParserKey("Black")]
public class BlackPipe : DrinkingWaterHeatingPipe public class BlackPipe : DrinkingWaterHeatingPipe
{ {
protected override string _title => "Black"; protected override string _title => "РЕХАУ BLACK";
protected override Dictionary<int, string> _diameterNames => new() protected override Dictionary<int, string> _diameterNames => new()
{ {
[16] = "16х2,2", [16] = "16х2,2",

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; output = string.Empty;
var diameterMatch = _diameter.Match(input); var diameterMatch = _diameter.Match(input);

View File

@ -3,5 +3,5 @@ namespace RhSolutions.Parsers.Pipes;
[ParserKey("Flex")] [ParserKey("Flex")]
public class FlexPipe : DrinkingWaterHeatingPipe public class FlexPipe : DrinkingWaterHeatingPipe
{ {
protected override string _title => "Flex"; protected override string _title => "РЕХАУ FLEX";
} }

View File

@ -3,7 +3,7 @@ namespace RhSolutions.Parsers.Pipes;
[ParserKey("Pink")] [ParserKey("Pink")]
public class PinkPipe : DrinkingWaterHeatingPipe public class PinkPipe : DrinkingWaterHeatingPipe
{ {
protected override string _title => "Pink+"; protected override string _title => "РЕХАУ PINK";
protected override Dictionary<string, string> _makeUp => new() protected override Dictionary<string, string> _makeUp => new()
{ {

View File

@ -14,4 +14,34 @@ public class StabilPipe : DrinkingWaterHeatingPipe
[50] = "50x6,9", [50] = "50x6,9",
[63] = "63x8,6" [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;
}
} }