summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--RhSolutions.Api.Tests/ProductQueryModifierTests.cs40
-rw-r--r--RhSolutions.Api.Tests/RhSolutions.Api.Tests.csproj23
-rw-r--r--RhSolutions.Api.Tests/Usings.cs1
-rw-r--r--RhSolutions.sln6
4 files changed, 70 insertions, 0 deletions
diff --git a/RhSolutions.Api.Tests/ProductQueryModifierTests.cs b/RhSolutions.Api.Tests/ProductQueryModifierTests.cs
new file mode 100644
index 0000000..32bc140
--- /dev/null
+++ b/RhSolutions.Api.Tests/ProductQueryModifierTests.cs
@@ -0,0 +1,40 @@
+using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.Primitives;
+using RhSolutions.Api.Services;
+
+namespace RhSolutions.Api.Tests;
+
+public class ProductQueryModifierTests
+{
+ private ProductQueryModifierFactory _factory;
+
+ [SetUp]
+ public void Setup()
+ {
+ _factory = new ProductQueryModifierFactory();
+ }
+
+ [TestCase("Монтажная гильза", "Гильза 16", "Монтажная гильза 16")]
+ [TestCase("Монтажная гильза", "Пресс-втулка 20", "Монтажная гильза 20")]
+ public void SleeveTest(string productType, string query, string modified) =>
+ Test(productType, query, modified);
+
+ [TestCase("Тройник RAUTITAN", "Тройник 20-16-16", "Тройник RAUTITAN -PLATINUM 20-16-16")]
+ [TestCase("Тройник RAUTITAN", "Тройник 20x16x16", "Тройник RAUTITAN -PLATINUM 20-16-16")]
+ public void TPieceTest(string productType, string query, string modified) =>
+ Test(productType, query, modified);
+
+ public void Test(string productType, string query, string modified)
+ {
+ Dictionary<string, StringValues> queryPair = new()
+ {
+ ["query"] = new StringValues(query)
+ };
+ QueryCollection collection = new(queryPair);
+ QueryString expected = new($"?query={Uri.EscapeDataString(modified)}");
+ var modifier = _factory.GetModifier(productType);
+ bool result = modifier.TryQueryModify(collection, out var actual);
+ Assert.True(result);
+ Assert.That(actual, Is.EqualTo(expected));
+ }
+} \ No newline at end of file
diff --git a/RhSolutions.Api.Tests/RhSolutions.Api.Tests.csproj b/RhSolutions.Api.Tests/RhSolutions.Api.Tests.csproj
new file mode 100644
index 0000000..4ce8b7c
--- /dev/null
+++ b/RhSolutions.Api.Tests/RhSolutions.Api.Tests.csproj
@@ -0,0 +1,23 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <TargetFramework>net6.0</TargetFramework>
+ <ImplicitUsings>enable</ImplicitUsings>
+ <Nullable>enable</Nullable>
+
+ <IsPackable>false</IsPackable>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
+ <PackageReference Include="NUnit" Version="3.13.3" />
+ <PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
+ <PackageReference Include="NUnit.Analyzers" Version="3.3.0" />
+ <PackageReference Include="coverlet.collector" Version="3.1.2" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="..\RhSolutions.Api\RhSolutions.Api.csproj" />
+ </ItemGroup>
+
+</Project>
diff --git a/RhSolutions.Api.Tests/Usings.cs b/RhSolutions.Api.Tests/Usings.cs
new file mode 100644
index 0000000..cefced4
--- /dev/null
+++ b/RhSolutions.Api.Tests/Usings.cs
@@ -0,0 +1 @@
+global using NUnit.Framework; \ No newline at end of file
diff --git a/RhSolutions.sln b/RhSolutions.sln
index 4e2c253..22fbf80 100644
--- a/RhSolutions.sln
+++ b/RhSolutions.sln
@@ -5,6 +5,8 @@ VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RhSolutions.Api", "RhSolutions.Api\RhSolutions.Api.csproj", "{FD778359-7E92-4B5C-A4F9-7942A28E58F5}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RhSolutions.Api.Tests", "RhSolutions.Api.Tests\RhSolutions.Api.Tests.csproj", "{9A4E9EFA-B854-4C29-AA94-A6CE074EDABA}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -18,5 +20,9 @@ Global
{FD778359-7E92-4B5C-A4F9-7942A28E58F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FD778359-7E92-4B5C-A4F9-7942A28E58F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FD778359-7E92-4B5C-A4F9-7942A28E58F5}.Release|Any CPU.Build.0 = Release|Any CPU
+ {9A4E9EFA-B854-4C29-AA94-A6CE074EDABA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9A4E9EFA-B854-4C29-AA94-A6CE074EDABA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9A4E9EFA-B854-4C29-AA94-A6CE074EDABA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9A4E9EFA-B854-4C29-AA94-A6CE074EDABA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal