jellyfin-server/tests/Jellyfin.Api.Tests/Middleware/UrlDecodeQueryFeatureTests.cs

28 lines
867 B
C#
Raw Permalink Normal View History

using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.Extensions.Primitives;
using Xunit;
2023-10-22 15:01:51 +00:00
namespace Jellyfin.Api.Middleware.Tests
{
public static class UrlDecodeQueryFeatureTests
{
[Theory]
[InlineData("e0a72cb2a2c7", "e0a72cb2a2c7")] // isn't encoded
public static void EmptyValueTest(string query, string key)
{
var dict = new Dictionary<string, StringValues>
{
{ query, StringValues.Empty }
};
var test = new UrlDecodeQueryFeature(new QueryFeature(new QueryCollection(dict)));
Assert.Single(test.Query);
var (k, v) = test.Query.First();
Assert.Equal(key, k);
2023-09-01 15:35:57 +00:00
Assert.True(StringValues.IsNullOrEmpty(v));
}
}
}