aboutsummaryrefslogtreecommitdiff
path: root/tests/Jellyfin.Api.Tests/Middleware/UrlDecodeQueryFeatureTests.cs
blob: 1ff7e7b7a41e1de3e45e09e239b148b03f5a64d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.Extensions.Primitives;
using Xunit;

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);
            Assert.True(StringValues.IsNullOrEmpty(v));
        }
    }
}