mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-06-03 13:44:22 -04:00
Fix warnings in test projects
This commit is contained in:
parent
b62b0ec2b5
commit
0fd36a5bf1
@ -109,7 +109,7 @@ public class UserControllerTests
|
|||||||
v.ErrorMessage.Contains("required", StringComparison.CurrentCultureIgnoreCase));
|
v.ErrorMessage.Contains("required", StringComparison.CurrentCultureIgnoreCase));
|
||||||
}
|
}
|
||||||
|
|
||||||
private IList<ValidationResult> Validate(object model)
|
private List<ValidationResult> Validate(object model)
|
||||||
{
|
{
|
||||||
var result = new List<ValidationResult>();
|
var result = new List<ValidationResult>();
|
||||||
var context = new ValidationContext(model, null, null);
|
var context = new ValidationContext(model, null, null);
|
||||||
|
@ -7,135 +7,128 @@ using Xunit;
|
|||||||
|
|
||||||
namespace Jellyfin.Extensions.Tests.Json.Converters
|
namespace Jellyfin.Extensions.Tests.Json.Converters
|
||||||
{
|
{
|
||||||
public static class JsonCommaDelimitedArrayTests
|
public class JsonCommaDelimitedArrayTests
|
||||||
{
|
{
|
||||||
[Fact]
|
private readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions()
|
||||||
public static void Deserialize_String_Null_Success()
|
|
||||||
{
|
{
|
||||||
var options = new JsonSerializerOptions();
|
Converters =
|
||||||
var value = JsonSerializer.Deserialize<GenericBodyArrayModel<string>>(@"{ ""Value"": null }", options);
|
{
|
||||||
|
new JsonStringEnumConverter()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Deserialize_String_Null_Success()
|
||||||
|
{
|
||||||
|
var value = JsonSerializer.Deserialize<GenericBodyArrayModel<string>>(@"{ ""Value"": null }", _jsonOptions);
|
||||||
Assert.Null(value?.Value);
|
Assert.Null(value?.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public static void Deserialize_Empty_Success()
|
public void Deserialize_Empty_Success()
|
||||||
{
|
{
|
||||||
var desiredValue = new GenericBodyArrayModel<string>
|
var desiredValue = new GenericBodyArrayModel<string>
|
||||||
{
|
{
|
||||||
Value = Array.Empty<string>()
|
Value = Array.Empty<string>()
|
||||||
};
|
};
|
||||||
|
|
||||||
var options = new JsonSerializerOptions();
|
var value = JsonSerializer.Deserialize<GenericBodyArrayModel<string>>(@"{ ""Value"": """" }", _jsonOptions);
|
||||||
var value = JsonSerializer.Deserialize<GenericBodyArrayModel<string>>(@"{ ""Value"": """" }", options);
|
|
||||||
Assert.Equal(desiredValue.Value, value?.Value);
|
Assert.Equal(desiredValue.Value, value?.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public static void Deserialize_String_Valid_Success()
|
public void Deserialize_String_Valid_Success()
|
||||||
{
|
{
|
||||||
var desiredValue = new GenericBodyArrayModel<string>
|
var desiredValue = new GenericBodyArrayModel<string>
|
||||||
{
|
{
|
||||||
Value = new[] { "a", "b", "c" }
|
Value = new[] { "a", "b", "c" }
|
||||||
};
|
};
|
||||||
|
|
||||||
var options = new JsonSerializerOptions();
|
var value = JsonSerializer.Deserialize<GenericBodyArrayModel<string>>(@"{ ""Value"": ""a,b,c"" }", _jsonOptions);
|
||||||
var value = JsonSerializer.Deserialize<GenericBodyArrayModel<string>>(@"{ ""Value"": ""a,b,c"" }", options);
|
|
||||||
Assert.Equal(desiredValue.Value, value?.Value);
|
Assert.Equal(desiredValue.Value, value?.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public static void Deserialize_String_Space_Valid_Success()
|
public void Deserialize_String_Space_Valid_Success()
|
||||||
{
|
{
|
||||||
var desiredValue = new GenericBodyArrayModel<string>
|
var desiredValue = new GenericBodyArrayModel<string>
|
||||||
{
|
{
|
||||||
Value = new[] { "a", "b", "c" }
|
Value = new[] { "a", "b", "c" }
|
||||||
};
|
};
|
||||||
|
|
||||||
var options = new JsonSerializerOptions();
|
var value = JsonSerializer.Deserialize<GenericBodyArrayModel<string>>(@"{ ""Value"": ""a, b, c"" }", _jsonOptions);
|
||||||
var value = JsonSerializer.Deserialize<GenericBodyArrayModel<string>>(@"{ ""Value"": ""a, b, c"" }", options);
|
|
||||||
Assert.Equal(desiredValue.Value, value?.Value);
|
Assert.Equal(desiredValue.Value, value?.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public static void Deserialize_GenericCommandType_Valid_Success()
|
public void Deserialize_GenericCommandType_Valid_Success()
|
||||||
{
|
{
|
||||||
var desiredValue = new GenericBodyArrayModel<GeneralCommandType>
|
var desiredValue = new GenericBodyArrayModel<GeneralCommandType>
|
||||||
{
|
{
|
||||||
Value = new[] { GeneralCommandType.MoveUp, GeneralCommandType.MoveDown }
|
Value = new[] { GeneralCommandType.MoveUp, GeneralCommandType.MoveDown }
|
||||||
};
|
};
|
||||||
|
|
||||||
var options = new JsonSerializerOptions();
|
var value = JsonSerializer.Deserialize<GenericBodyArrayModel<GeneralCommandType>>(@"{ ""Value"": ""MoveUp,MoveDown"" }", _jsonOptions);
|
||||||
options.Converters.Add(new JsonStringEnumConverter());
|
|
||||||
var value = JsonSerializer.Deserialize<GenericBodyArrayModel<GeneralCommandType>>(@"{ ""Value"": ""MoveUp,MoveDown"" }", options);
|
|
||||||
Assert.Equal(desiredValue.Value, value?.Value);
|
Assert.Equal(desiredValue.Value, value?.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public static void Deserialize_GenericCommandType_EmptyEntry_Success()
|
public void Deserialize_GenericCommandType_EmptyEntry_Success()
|
||||||
{
|
{
|
||||||
var desiredValue = new GenericBodyArrayModel<GeneralCommandType>
|
var desiredValue = new GenericBodyArrayModel<GeneralCommandType>
|
||||||
{
|
{
|
||||||
Value = new[] { GeneralCommandType.MoveUp, GeneralCommandType.MoveDown }
|
Value = new[] { GeneralCommandType.MoveUp, GeneralCommandType.MoveDown }
|
||||||
};
|
};
|
||||||
|
|
||||||
var options = new JsonSerializerOptions();
|
var value = JsonSerializer.Deserialize<GenericBodyArrayModel<GeneralCommandType>>(@"{ ""Value"": ""MoveUp,,MoveDown"" }", _jsonOptions);
|
||||||
options.Converters.Add(new JsonStringEnumConverter());
|
|
||||||
var value = JsonSerializer.Deserialize<GenericBodyArrayModel<GeneralCommandType>>(@"{ ""Value"": ""MoveUp,,MoveDown"" }", options);
|
|
||||||
Assert.Equal(desiredValue.Value, value?.Value);
|
Assert.Equal(desiredValue.Value, value?.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public static void Deserialize_GenericCommandType_Invalid_Success()
|
public void Deserialize_GenericCommandType_Invalid_Success()
|
||||||
{
|
{
|
||||||
var desiredValue = new GenericBodyArrayModel<GeneralCommandType>
|
var desiredValue = new GenericBodyArrayModel<GeneralCommandType>
|
||||||
{
|
{
|
||||||
Value = new[] { GeneralCommandType.MoveUp, GeneralCommandType.MoveDown }
|
Value = new[] { GeneralCommandType.MoveUp, GeneralCommandType.MoveDown }
|
||||||
};
|
};
|
||||||
|
|
||||||
var options = new JsonSerializerOptions();
|
var value = JsonSerializer.Deserialize<GenericBodyArrayModel<GeneralCommandType>>(@"{ ""Value"": ""MoveUp,TotallyNotAVallidCommand,MoveDown"" }", _jsonOptions);
|
||||||
options.Converters.Add(new JsonStringEnumConverter());
|
|
||||||
var value = JsonSerializer.Deserialize<GenericBodyArrayModel<GeneralCommandType>>(@"{ ""Value"": ""MoveUp,TotallyNotAVallidCommand,MoveDown"" }", options);
|
|
||||||
Assert.Equal(desiredValue.Value, value?.Value);
|
Assert.Equal(desiredValue.Value, value?.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public static void Deserialize_GenericCommandType_Space_Valid_Success()
|
public void Deserialize_GenericCommandType_Space_Valid_Success()
|
||||||
{
|
{
|
||||||
var desiredValue = new GenericBodyArrayModel<GeneralCommandType>
|
var desiredValue = new GenericBodyArrayModel<GeneralCommandType>
|
||||||
{
|
{
|
||||||
Value = new[] { GeneralCommandType.MoveUp, GeneralCommandType.MoveDown }
|
Value = new[] { GeneralCommandType.MoveUp, GeneralCommandType.MoveDown }
|
||||||
};
|
};
|
||||||
|
|
||||||
var options = new JsonSerializerOptions();
|
var value = JsonSerializer.Deserialize<GenericBodyArrayModel<GeneralCommandType>>(@"{ ""Value"": ""MoveUp, MoveDown"" }", _jsonOptions);
|
||||||
options.Converters.Add(new JsonStringEnumConverter());
|
|
||||||
var value = JsonSerializer.Deserialize<GenericBodyArrayModel<GeneralCommandType>>(@"{ ""Value"": ""MoveUp, MoveDown"" }", options);
|
|
||||||
Assert.Equal(desiredValue.Value, value?.Value);
|
Assert.Equal(desiredValue.Value, value?.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public static void Deserialize_String_Array_Valid_Success()
|
public void Deserialize_String_Array_Valid_Success()
|
||||||
{
|
{
|
||||||
var desiredValue = new GenericBodyArrayModel<string>
|
var desiredValue = new GenericBodyArrayModel<string>
|
||||||
{
|
{
|
||||||
Value = new[] { "a", "b", "c" }
|
Value = new[] { "a", "b", "c" }
|
||||||
};
|
};
|
||||||
|
|
||||||
var options = new JsonSerializerOptions();
|
var value = JsonSerializer.Deserialize<GenericBodyArrayModel<string>>(@"{ ""Value"": [""a"",""b"",""c""] }", _jsonOptions);
|
||||||
var value = JsonSerializer.Deserialize<GenericBodyArrayModel<string>>(@"{ ""Value"": [""a"",""b"",""c""] }", options);
|
|
||||||
Assert.Equal(desiredValue.Value, value?.Value);
|
Assert.Equal(desiredValue.Value, value?.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public static void Deserialize_GenericCommandType_Array_Valid_Success()
|
public void Deserialize_GenericCommandType_Array_Valid_Success()
|
||||||
{
|
{
|
||||||
var desiredValue = new GenericBodyArrayModel<GeneralCommandType>
|
var desiredValue = new GenericBodyArrayModel<GeneralCommandType>
|
||||||
{
|
{
|
||||||
Value = new[] { GeneralCommandType.MoveUp, GeneralCommandType.MoveDown }
|
Value = new[] { GeneralCommandType.MoveUp, GeneralCommandType.MoveDown }
|
||||||
};
|
};
|
||||||
|
|
||||||
var options = new JsonSerializerOptions();
|
var value = JsonSerializer.Deserialize<GenericBodyArrayModel<GeneralCommandType>>(@"{ ""Value"": [""MoveUp"", ""MoveDown""] }", _jsonOptions);
|
||||||
options.Converters.Add(new JsonStringEnumConverter());
|
|
||||||
var value = JsonSerializer.Deserialize<GenericBodyArrayModel<GeneralCommandType>>(@"{ ""Value"": [""MoveUp"", ""MoveDown""] }", options);
|
|
||||||
Assert.Equal(desiredValue.Value, value?.Value);
|
Assert.Equal(desiredValue.Value, value?.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,86 +6,85 @@ using Xunit;
|
|||||||
|
|
||||||
namespace Jellyfin.Extensions.Tests.Json.Converters
|
namespace Jellyfin.Extensions.Tests.Json.Converters
|
||||||
{
|
{
|
||||||
public static class JsonCommaDelimitedIReadOnlyListTests
|
public class JsonCommaDelimitedIReadOnlyListTests
|
||||||
{
|
{
|
||||||
|
private readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions()
|
||||||
|
{
|
||||||
|
Converters =
|
||||||
|
{
|
||||||
|
new JsonStringEnumConverter()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public static void Deserialize_String_Valid_Success()
|
public void Deserialize_String_Valid_Success()
|
||||||
{
|
{
|
||||||
var desiredValue = new GenericBodyIReadOnlyListModel<string>
|
var desiredValue = new GenericBodyIReadOnlyListModel<string>
|
||||||
{
|
{
|
||||||
Value = new[] { "a", "b", "c" }
|
Value = new[] { "a", "b", "c" }
|
||||||
};
|
};
|
||||||
|
|
||||||
var options = new JsonSerializerOptions();
|
var value = JsonSerializer.Deserialize<GenericBodyIReadOnlyListModel<string>>(@"{ ""Value"": ""a,b,c"" }", _jsonOptions);
|
||||||
var value = JsonSerializer.Deserialize<GenericBodyIReadOnlyListModel<string>>(@"{ ""Value"": ""a,b,c"" }", options);
|
|
||||||
Assert.Equal(desiredValue.Value, value?.Value);
|
Assert.Equal(desiredValue.Value, value?.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public static void Deserialize_String_Space_Valid_Success()
|
public void Deserialize_String_Space_Valid_Success()
|
||||||
{
|
{
|
||||||
var desiredValue = new GenericBodyIReadOnlyListModel<string>
|
var desiredValue = new GenericBodyIReadOnlyListModel<string>
|
||||||
{
|
{
|
||||||
Value = new[] { "a", "b", "c" }
|
Value = new[] { "a", "b", "c" }
|
||||||
};
|
};
|
||||||
|
|
||||||
var options = new JsonSerializerOptions();
|
var value = JsonSerializer.Deserialize<GenericBodyIReadOnlyListModel<string>>(@"{ ""Value"": ""a, b, c"" }", _jsonOptions);
|
||||||
var value = JsonSerializer.Deserialize<GenericBodyIReadOnlyListModel<string>>(@"{ ""Value"": ""a, b, c"" }", options);
|
|
||||||
Assert.Equal(desiredValue.Value, value?.Value);
|
Assert.Equal(desiredValue.Value, value?.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public static void Deserialize_GenericCommandType_Valid_Success()
|
public void Deserialize_GenericCommandType_Valid_Success()
|
||||||
{
|
{
|
||||||
var desiredValue = new GenericBodyIReadOnlyListModel<GeneralCommandType>
|
var desiredValue = new GenericBodyIReadOnlyListModel<GeneralCommandType>
|
||||||
{
|
{
|
||||||
Value = new[] { GeneralCommandType.MoveUp, GeneralCommandType.MoveDown }
|
Value = new[] { GeneralCommandType.MoveUp, GeneralCommandType.MoveDown }
|
||||||
};
|
};
|
||||||
|
|
||||||
var options = new JsonSerializerOptions();
|
var value = JsonSerializer.Deserialize<GenericBodyIReadOnlyListModel<GeneralCommandType>>(@"{ ""Value"": ""MoveUp,MoveDown"" }", _jsonOptions);
|
||||||
options.Converters.Add(new JsonStringEnumConverter());
|
|
||||||
var value = JsonSerializer.Deserialize<GenericBodyIReadOnlyListModel<GeneralCommandType>>(@"{ ""Value"": ""MoveUp,MoveDown"" }", options);
|
|
||||||
Assert.Equal(desiredValue.Value, value?.Value);
|
Assert.Equal(desiredValue.Value, value?.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public static void Deserialize_GenericCommandType_Space_Valid_Success()
|
public void Deserialize_GenericCommandType_Space_Valid_Success()
|
||||||
{
|
{
|
||||||
var desiredValue = new GenericBodyIReadOnlyListModel<GeneralCommandType>
|
var desiredValue = new GenericBodyIReadOnlyListModel<GeneralCommandType>
|
||||||
{
|
{
|
||||||
Value = new[] { GeneralCommandType.MoveUp, GeneralCommandType.MoveDown }
|
Value = new[] { GeneralCommandType.MoveUp, GeneralCommandType.MoveDown }
|
||||||
};
|
};
|
||||||
|
|
||||||
var options = new JsonSerializerOptions();
|
var value = JsonSerializer.Deserialize<GenericBodyIReadOnlyListModel<GeneralCommandType>>(@"{ ""Value"": ""MoveUp, MoveDown"" }", _jsonOptions);
|
||||||
options.Converters.Add(new JsonStringEnumConverter());
|
|
||||||
var value = JsonSerializer.Deserialize<GenericBodyIReadOnlyListModel<GeneralCommandType>>(@"{ ""Value"": ""MoveUp, MoveDown"" }", options);
|
|
||||||
Assert.Equal(desiredValue.Value, value?.Value);
|
Assert.Equal(desiredValue.Value, value?.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public static void Deserialize_String_Array_Valid_Success()
|
public void Deserialize_String_Array_Valid_Success()
|
||||||
{
|
{
|
||||||
var desiredValue = new GenericBodyIReadOnlyListModel<string>
|
var desiredValue = new GenericBodyIReadOnlyListModel<string>
|
||||||
{
|
{
|
||||||
Value = new[] { "a", "b", "c" }
|
Value = new[] { "a", "b", "c" }
|
||||||
};
|
};
|
||||||
|
|
||||||
var options = new JsonSerializerOptions();
|
var value = JsonSerializer.Deserialize<GenericBodyIReadOnlyListModel<string>>(@"{ ""Value"": [""a"",""b"",""c""] }", _jsonOptions);
|
||||||
var value = JsonSerializer.Deserialize<GenericBodyIReadOnlyListModel<string>>(@"{ ""Value"": [""a"",""b"",""c""] }", options);
|
|
||||||
Assert.Equal(desiredValue.Value, value?.Value);
|
Assert.Equal(desiredValue.Value, value?.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public static void Deserialize_GenericCommandType_Array_Valid_Success()
|
public void Deserialize_GenericCommandType_Array_Valid_Success()
|
||||||
{
|
{
|
||||||
var desiredValue = new GenericBodyIReadOnlyListModel<GeneralCommandType>
|
var desiredValue = new GenericBodyIReadOnlyListModel<GeneralCommandType>
|
||||||
{
|
{
|
||||||
Value = new[] { GeneralCommandType.MoveUp, GeneralCommandType.MoveDown }
|
Value = new[] { GeneralCommandType.MoveUp, GeneralCommandType.MoveDown }
|
||||||
};
|
};
|
||||||
|
|
||||||
var options = new JsonSerializerOptions();
|
var value = JsonSerializer.Deserialize<GenericBodyIReadOnlyListModel<GeneralCommandType>>(@"{ ""Value"": [""MoveUp"", ""MoveDown""] }", _jsonOptions);
|
||||||
options.Converters.Add(new JsonStringEnumConverter());
|
|
||||||
var value = JsonSerializer.Deserialize<GenericBodyIReadOnlyListModel<GeneralCommandType>>(@"{ ""Value"": [""MoveUp"", ""MoveDown""] }", options);
|
|
||||||
Assert.Equal(desiredValue.Value, value?.Value);
|
Assert.Equal(desiredValue.Value, value?.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ using Microsoft.Extensions.Configuration;
|
|||||||
using Microsoft.Extensions.Logging.Abstractions;
|
using Microsoft.Extensions.Logging.Abstractions;
|
||||||
using Moq;
|
using Moq;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
using IConfigurationManager = MediaBrowser.Common.Configuration.IConfigurationManager;
|
||||||
|
|
||||||
namespace Jellyfin.Networking.Tests
|
namespace Jellyfin.Networking.Tests
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,7 @@ namespace Jellyfin.Providers.Tests.Manager
|
|||||||
{
|
{
|
||||||
public partial class ItemImageProviderTests
|
public partial class ItemImageProviderTests
|
||||||
{
|
{
|
||||||
private const string TestDataImagePath = "Test Data/Images/blank{0}.jpg";
|
private static readonly CompositeFormat _testDataImagePath = CompositeFormat.Parse("Test Data/Images/blank{0}.jpg");
|
||||||
|
|
||||||
[GeneratedRegex("[0-9]+")]
|
[GeneratedRegex("[0-9]+")]
|
||||||
private static partial Regex NumbersRegex();
|
private static partial Regex NumbersRegex();
|
||||||
@ -275,7 +275,7 @@ namespace Jellyfin.Providers.Tests.Manager
|
|||||||
{
|
{
|
||||||
HasImage = true,
|
HasImage = true,
|
||||||
Format = ImageFormat.Jpg,
|
Format = ImageFormat.Jpg,
|
||||||
Path = responseHasPath ? string.Format(CultureInfo.InvariantCulture, TestDataImagePath, 0) : null,
|
Path = responseHasPath ? string.Format(CultureInfo.InvariantCulture, _testDataImagePath, 0) : null,
|
||||||
Protocol = protocol
|
Protocol = protocol
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -563,21 +563,21 @@ namespace Jellyfin.Providers.Tests.Manager
|
|||||||
mockFileSystem.Setup(fs => fs.GetFilePaths(It.IsAny<string>(), It.IsAny<bool>()))
|
mockFileSystem.Setup(fs => fs.GetFilePaths(It.IsAny<string>(), It.IsAny<bool>()))
|
||||||
.Returns(new[]
|
.Returns(new[]
|
||||||
{
|
{
|
||||||
string.Format(CultureInfo.InvariantCulture, TestDataImagePath, 0),
|
string.Format(CultureInfo.InvariantCulture, _testDataImagePath, 0),
|
||||||
string.Format(CultureInfo.InvariantCulture, TestDataImagePath, 1)
|
string.Format(CultureInfo.InvariantCulture, _testDataImagePath, 1)
|
||||||
});
|
});
|
||||||
|
|
||||||
return new ItemImageProvider(new NullLogger<ItemImageProvider>(), providerManager, mockFileSystem.Object);
|
return new ItemImageProvider(new NullLogger<ItemImageProvider>(), providerManager, mockFileSystem.Object);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BaseItem GetItemWithImages(ImageType type, int count, bool validPaths)
|
private static Video GetItemWithImages(ImageType type, int count, bool validPaths)
|
||||||
{
|
{
|
||||||
// Has to exist for querying DateModified time on file, results stored but not checked so not populating
|
// Has to exist for querying DateModified time on file, results stored but not checked so not populating
|
||||||
BaseItem.FileSystem ??= Mock.Of<IFileSystem>();
|
BaseItem.FileSystem ??= Mock.Of<IFileSystem>();
|
||||||
|
|
||||||
var item = new Video();
|
var item = new Video();
|
||||||
|
|
||||||
var path = validPaths ? TestDataImagePath : "invalid path {0}";
|
var path = validPaths ? _testDataImagePath.Format : "invalid path {0}";
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
item.SetImagePath(type, i, new FileSystemMetadata
|
item.SetImagePath(type, i, new FileSystemMetadata
|
||||||
@ -604,7 +604,7 @@ namespace Jellyfin.Providers.Tests.Manager
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private static LocalImageInfo[] GetImages(ImageType type, int count, bool validPaths)
|
private static LocalImageInfo[] GetImages(ImageType type, int count, bool validPaths)
|
||||||
{
|
{
|
||||||
var path = validPaths ? TestDataImagePath : "invalid path {0}";
|
var path = validPaths ? _testDataImagePath.Format : "invalid path {0}";
|
||||||
var images = new LocalImageInfo[count];
|
var images = new LocalImageInfo[count];
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
|
@ -9,22 +9,21 @@ namespace Jellyfin.Server.Implementations.Tests.Sorting
|
|||||||
{
|
{
|
||||||
public class AiredEpisodeOrderComparerTests
|
public class AiredEpisodeOrderComparerTests
|
||||||
{
|
{
|
||||||
|
private readonly AiredEpisodeOrderComparer _cmp = new AiredEpisodeOrderComparer();
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
[ClassData(typeof(EpisodeBadData))]
|
[ClassData(typeof(EpisodeBadData))]
|
||||||
public void Compare_GivenNull_ThrowsArgumentNullException(BaseItem? x, BaseItem? y)
|
public void Compare_GivenNull_ThrowsArgumentNullException(BaseItem? x, BaseItem? y)
|
||||||
{
|
{
|
||||||
var cmp = new AiredEpisodeOrderComparer();
|
Assert.Throws<ArgumentNullException>(() => _cmp.Compare(x, y));
|
||||||
Assert.Throws<ArgumentNullException>(() => cmp.Compare(x, y));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
[ClassData(typeof(EpisodeTestData))]
|
[ClassData(typeof(EpisodeTestData))]
|
||||||
public void AiredEpisodeOrderCompareTest(BaseItem x, BaseItem y, int expected)
|
public void AiredEpisodeOrderCompareTest(BaseItem x, BaseItem y, int expected)
|
||||||
{
|
{
|
||||||
var cmp = new AiredEpisodeOrderComparer();
|
Assert.Equal(expected, _cmp.Compare(x, y));
|
||||||
|
Assert.Equal(-expected, _cmp.Compare(y, x));
|
||||||
Assert.Equal(expected, cmp.Compare(x, y));
|
|
||||||
Assert.Equal(-expected, cmp.Compare(y, x));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private sealed class EpisodeBadData : TheoryData<BaseItem?, BaseItem?>
|
private sealed class EpisodeBadData : TheoryData<BaseItem?, BaseItem?>
|
||||||
|
@ -9,7 +9,7 @@ namespace Jellyfin.Server.Implementations.Tests.Sorting;
|
|||||||
|
|
||||||
public class IndexNumberComparerTests
|
public class IndexNumberComparerTests
|
||||||
{
|
{
|
||||||
private readonly IBaseItemComparer _cmp = new IndexNumberComparer();
|
private readonly IndexNumberComparer _cmp = new IndexNumberComparer();
|
||||||
|
|
||||||
public static TheoryData<BaseItem?, BaseItem?> Compare_GivenNull_ThrowsArgumentNullException_TestData()
|
public static TheoryData<BaseItem?, BaseItem?> Compare_GivenNull_ThrowsArgumentNullException_TestData()
|
||||||
=> new()
|
=> new()
|
||||||
|
@ -9,7 +9,7 @@ namespace Jellyfin.Server.Implementations.Tests.Sorting;
|
|||||||
|
|
||||||
public class ParentIndexNumberComparerTests
|
public class ParentIndexNumberComparerTests
|
||||||
{
|
{
|
||||||
private readonly IBaseItemComparer _cmp = new ParentIndexNumberComparer();
|
private readonly ParentIndexNumberComparer _cmp = new ParentIndexNumberComparer();
|
||||||
|
|
||||||
public static TheoryData<BaseItem?, BaseItem?> Compare_GivenNull_ThrowsArgumentNullException_TestData()
|
public static TheoryData<BaseItem?, BaseItem?> Compare_GivenNull_ThrowsArgumentNullException_TestData()
|
||||||
=> new()
|
=> new()
|
||||||
|
@ -10,6 +10,7 @@ using Microsoft.Extensions.Configuration;
|
|||||||
using Microsoft.Extensions.Logging.Abstractions;
|
using Microsoft.Extensions.Logging.Abstractions;
|
||||||
using Moq;
|
using Moq;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
using IConfigurationManager = MediaBrowser.Common.Configuration.IConfigurationManager;
|
||||||
|
|
||||||
namespace Jellyfin.Server.Tests
|
namespace Jellyfin.Server.Tests
|
||||||
{
|
{
|
||||||
@ -98,7 +99,7 @@ namespace Jellyfin.Server.Tests
|
|||||||
Assert.Equal(knownNetworks.Length, options.KnownNetworks.Count);
|
Assert.Equal(knownNetworks.Length, options.KnownNetworks.Count);
|
||||||
foreach (var item in knownNetworks)
|
foreach (var item in knownNetworks)
|
||||||
{
|
{
|
||||||
Assert.NotNull(options.KnownNetworks.FirstOrDefault(x => x.BaseAddress.Equals(item.BaseAddress) && x.PrefixLength == item.PrefixLength));
|
Assert.NotNull(options.KnownNetworks.FirstOrDefault(x => x.Prefix.Equals(item.BaseAddress) && x.PrefixLength == item.PrefixLength));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user