27 lines
780 B
C#
27 lines
780 B
C#
using System.Web;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.Extensions.Primitives;
|
|
using RhSolutions.Api.Services;
|
|
public abstract class ProductQueryModifierTests
|
|
{
|
|
protected ProductQueryModifierFactory _factory;
|
|
|
|
[SetUp]
|
|
public void Setup()
|
|
{
|
|
_factory = new ProductQueryModifierFactory();
|
|
}
|
|
public void Execute(string productType, string query, string modified)
|
|
{
|
|
Dictionary<string, StringValues> queryPair = new()
|
|
{
|
|
["query"] = new StringValues(query)
|
|
};
|
|
QueryCollection collection = new(queryPair);
|
|
var modifier = _factory.GetModifier(productType);
|
|
|
|
Assert.True(modifier.TryQueryModify(collection, out var actual));
|
|
string? result = HttpUtility.ParseQueryString(actual.ToString())["query"];
|
|
Assert.That(result, Is.EqualTo(modified));
|
|
}
|
|
} |