2023-09-29 10:07:41 +03:00
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
using Microsoft.Extensions.Primitives;
|
|
|
|
using RhSolutions.Api.Services;
|
2023-10-03 21:57:33 +03:00
|
|
|
public abstract class ProductQueryModifierTests
|
2023-09-29 10:07:41 +03:00
|
|
|
{
|
2023-10-03 21:57:33 +03:00
|
|
|
protected ProductQueryModifierFactory _factory;
|
2023-09-29 10:07:41 +03:00
|
|
|
|
2023-10-01 22:14:47 +03:00
|
|
|
[SetUp]
|
|
|
|
public void Setup()
|
|
|
|
{
|
|
|
|
_factory = new ProductQueryModifierFactory();
|
|
|
|
}
|
2023-10-03 21:57:33 +03:00
|
|
|
public void Execute(string productType, string query, string modified)
|
2023-10-01 22:14:47 +03:00
|
|
|
{
|
|
|
|
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));
|
|
|
|
}
|
2023-09-29 10:07:41 +03:00
|
|
|
}
|