0
0
RhSolutions-Api/RhSolutions.Api.Tests/ProductQueryModifierTests.cs

26 lines
778 B
C#

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);
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));
}
}