|
|
|
@ -17,7 +17,7 @@ namespace Jellyfin.Api.Tests.ModelBinders
|
|
|
|
|
public async Task BindModelAsync_CorrectlyBindsValidCommaDelimitedStringArrayQuery()
|
|
|
|
|
{
|
|
|
|
|
var queryParamName = "test";
|
|
|
|
|
var queryParamValues = new[] { "lol", "xd" };
|
|
|
|
|
IReadOnlyList<string> queryParamValues = new[] { "lol", "xd" };
|
|
|
|
|
var queryParamString = "lol,xd";
|
|
|
|
|
var queryParamType = typeof(string[]);
|
|
|
|
|
|
|
|
|
@ -35,14 +35,14 @@ namespace Jellyfin.Api.Tests.ModelBinders
|
|
|
|
|
await modelBinder.BindModelAsync(bindingContextMock.Object);
|
|
|
|
|
|
|
|
|
|
Assert.True(bindingContextMock.Object.Result.IsModelSet);
|
|
|
|
|
Assert.Equal((string[])bindingContextMock.Object.Result.Model, queryParamValues);
|
|
|
|
|
Assert.Equal((IReadOnlyList<string>?)bindingContextMock.Object?.Result.Model, queryParamValues);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task BindModelAsync_CorrectlyBindsValidCommaDelimitedIntArrayQuery()
|
|
|
|
|
{
|
|
|
|
|
var queryParamName = "test";
|
|
|
|
|
var queryParamValues = new[] { 42, 0 };
|
|
|
|
|
IReadOnlyList<int> queryParamValues = new[] { 42, 0 };
|
|
|
|
|
var queryParamString = "42,0";
|
|
|
|
|
var queryParamType = typeof(int[]);
|
|
|
|
|
|
|
|
|
@ -60,14 +60,14 @@ namespace Jellyfin.Api.Tests.ModelBinders
|
|
|
|
|
await modelBinder.BindModelAsync(bindingContextMock.Object);
|
|
|
|
|
|
|
|
|
|
Assert.True(bindingContextMock.Object.Result.IsModelSet);
|
|
|
|
|
Assert.Equal((int[])bindingContextMock.Object.Result.Model, queryParamValues);
|
|
|
|
|
Assert.Equal((IReadOnlyList<int>?)bindingContextMock.Object.Result.Model, queryParamValues);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task BindModelAsync_CorrectlyBindsValidCommaDelimitedEnumArrayQuery()
|
|
|
|
|
{
|
|
|
|
|
var queryParamName = "test";
|
|
|
|
|
var queryParamValues = new[] { TestType.How, TestType.Much };
|
|
|
|
|
IReadOnlyList<TestType> queryParamValues = new[] { TestType.How, TestType.Much };
|
|
|
|
|
var queryParamString = "How,Much";
|
|
|
|
|
var queryParamType = typeof(TestType[]);
|
|
|
|
|
|
|
|
|
@ -85,14 +85,14 @@ namespace Jellyfin.Api.Tests.ModelBinders
|
|
|
|
|
await modelBinder.BindModelAsync(bindingContextMock.Object);
|
|
|
|
|
|
|
|
|
|
Assert.True(bindingContextMock.Object.Result.IsModelSet);
|
|
|
|
|
Assert.Equal((TestType[])bindingContextMock.Object.Result.Model, queryParamValues);
|
|
|
|
|
Assert.Equal((IReadOnlyList<TestType>?)bindingContextMock.Object.Result.Model, queryParamValues);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task BindModelAsync_CorrectlyBindsValidCommaDelimitedEnumArrayQueryWithDoubleCommas()
|
|
|
|
|
{
|
|
|
|
|
var queryParamName = "test";
|
|
|
|
|
var queryParamValues = new[] { TestType.How, TestType.Much };
|
|
|
|
|
IReadOnlyList<TestType> queryParamValues = new[] { TestType.How, TestType.Much };
|
|
|
|
|
var queryParamString = "How,,Much";
|
|
|
|
|
var queryParamType = typeof(TestType[]);
|
|
|
|
|
|
|
|
|
@ -110,14 +110,14 @@ namespace Jellyfin.Api.Tests.ModelBinders
|
|
|
|
|
await modelBinder.BindModelAsync(bindingContextMock.Object);
|
|
|
|
|
|
|
|
|
|
Assert.True(bindingContextMock.Object.Result.IsModelSet);
|
|
|
|
|
Assert.Equal((TestType[])bindingContextMock.Object.Result.Model, queryParamValues);
|
|
|
|
|
Assert.Equal((IReadOnlyList<TestType>?)bindingContextMock.Object.Result.Model, queryParamValues);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task BindModelAsync_CorrectlyBindsValidEnumArrayQuery()
|
|
|
|
|
{
|
|
|
|
|
var queryParamName = "test";
|
|
|
|
|
var queryParamValues = new[] { TestType.How, TestType.Much };
|
|
|
|
|
IReadOnlyList<TestType> queryParamValues = new[] { TestType.How, TestType.Much };
|
|
|
|
|
var queryParamString1 = "How";
|
|
|
|
|
var queryParamString2 = "Much";
|
|
|
|
|
var queryParamType = typeof(TestType[]);
|
|
|
|
@ -140,14 +140,14 @@ namespace Jellyfin.Api.Tests.ModelBinders
|
|
|
|
|
await modelBinder.BindModelAsync(bindingContextMock.Object);
|
|
|
|
|
|
|
|
|
|
Assert.True(bindingContextMock.Object.Result.IsModelSet);
|
|
|
|
|
Assert.Equal((TestType[])bindingContextMock.Object.Result.Model, queryParamValues);
|
|
|
|
|
Assert.Equal((IReadOnlyList<TestType>?)bindingContextMock.Object.Result.Model, queryParamValues);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task BindModelAsync_CorrectlyBindsEmptyEnumArrayQuery()
|
|
|
|
|
{
|
|
|
|
|
var queryParamName = "test";
|
|
|
|
|
var queryParamValues = Array.Empty<TestType>();
|
|
|
|
|
IReadOnlyList<TestType> queryParamValues = Array.Empty<TestType>();
|
|
|
|
|
var queryParamType = typeof(TestType[]);
|
|
|
|
|
|
|
|
|
|
var modelBinder = new CommaDelimitedArrayModelBinder();
|
|
|
|
@ -168,7 +168,7 @@ namespace Jellyfin.Api.Tests.ModelBinders
|
|
|
|
|
await modelBinder.BindModelAsync(bindingContextMock.Object);
|
|
|
|
|
|
|
|
|
|
Assert.True(bindingContextMock.Object.Result.IsModelSet);
|
|
|
|
|
Assert.Equal((TestType[])bindingContextMock.Object.Result.Model, queryParamValues);
|
|
|
|
|
Assert.Equal((IReadOnlyList<TestType>?)bindingContextMock.Object.Result.Model, queryParamValues);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|