e81c127514
- Add JSON-based config loading with XML fallback for DB and library options - Implement LibraryOptionsRepository with EF Core, migrations, and entity - Update CollectionFolder to use DB-backed options with XML fallback/backfill - Register repository in DI and initialize at startup - Use EF execution strategy for transactional DB operations - Suppress code analysis warnings in .csproj and test files - Add DATABASE_MIGRATION.md, LIBRARY_OPTIONS_DB_DESIGN.md, and WEBSOCKET_AUTHENTICATION.md - Add database.json.example and improve migration docs - Add tests for JSON config loader and update test naming warnings
84 lines
3.5 KiB
C#
84 lines
3.5 KiB
C#
// <copyright file="CopyToExtensionsTests.cs" company="PlaceholderCompany">
|
|
// Copyright (c) PlaceholderCompany. All rights reserved.
|
|
// </copyright>
|
|
|
|
#pragma warning disable CA1707 // Identifiers should not contain underscores - xUnit test naming convention
|
|
#pragma warning disable CA1861 // Avoid constant arrays as arguments - required for xUnit theory test data
|
|
|
|
namespace Jellyfin.Extensions.Tests
|
|
{
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using Xunit;
|
|
|
|
/// <summary>
|
|
/// Tests for CopyTo extension methods.
|
|
/// </summary>
|
|
public static class CopyToExtensionsTests
|
|
{
|
|
/// <summary>
|
|
/// Gets test data for valid CopyTo operations.
|
|
/// </summary>
|
|
/// <returns>The test data.</returns>
|
|
public static TheoryData<IReadOnlyList<int>, IList<int>, int, IList<int>> CopyTo_Valid_Correct_TestData()
|
|
{
|
|
TheoryData<IReadOnlyList<int>, IList<int>, int, IList<int>> data = new TheoryData<IReadOnlyList<int>, IList<int>, int, IList<int>>
|
|
{
|
|
{ new[] { 0, 1, 2, 3, 4, 5 }, new[] { 0, 0, 0, 0, 0, 0 }, 0, new[] { 0, 1, 2, 3, 4, 5 } },
|
|
{ new[] { 0, 1, 2 }, new[] { 5, 4, 3, 2, 1, 0 }, 2, new[] { 5, 4, 0, 1, 2, 0 } },
|
|
};
|
|
|
|
return data;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Tests that CopyTo correctly copies elements.
|
|
/// </summary>
|
|
/// <param name="source">The source list.</param>
|
|
/// <param name="destination">The destination list.</param>
|
|
/// <param name="index">The starting index.</param>
|
|
/// <param name="expected">The expected result.</param>
|
|
[Theory]
|
|
[MemberData(nameof(CopyTo_Valid_Correct_TestData))]
|
|
public static void CopyTo_Valid_Correct(IReadOnlyList<int> source, IList<int> destination, int index, IList<int> expected)
|
|
{
|
|
source.CopyTo(destination, index);
|
|
Assert.Equal(expected, destination);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets test data for invalid CopyTo operations that should throw.
|
|
/// </summary>
|
|
/// <returns>The test data.</returns>
|
|
public static TheoryData<IReadOnlyList<int>, IList<int>, int> CopyTo_Invalid_ThrowsArgumentOutOfRangeException_TestData()
|
|
{
|
|
TheoryData<IReadOnlyList<int>, IList<int>, int> data = new TheoryData<IReadOnlyList<int>, IList<int>, int>
|
|
{
|
|
{ new[] { 0, 1, 2, 3, 4, 5 }, new[] { 0, 0, 0, 0, 0, 0 }, -1 },
|
|
{ new[] { 0, 1, 2 }, new[] { 5, 4, 3, 2, 1, 0 }, 6 },
|
|
{ new[] { 0, 1, 2 }, Array.Empty<int>(), 0 },
|
|
{ new[] { 0, 1, 2, 3, 4, 5 }, new[] { 0 }, 0 },
|
|
{ new[] { 0, 1, 2, 3, 4, 5 }, new[] { 0, 0, 0, 0, 0, 0 }, 1 },
|
|
};
|
|
|
|
return data;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Tests that CopyTo throws ArgumentOutOfRangeException for invalid inputs.
|
|
/// </summary>
|
|
/// <param name="source">The source list.</param>
|
|
/// <param name="destination">The destination list.</param>
|
|
/// <param name="index">The starting index.</param>
|
|
[Theory]
|
|
[MemberData(nameof(CopyTo_Invalid_ThrowsArgumentOutOfRangeException_TestData))]
|
|
public static void CopyTo_Invalid_ThrowsArgumentOutOfRangeException(IReadOnlyList<int> source, IList<int> destination, int index)
|
|
{
|
|
Assert.Throws<ArgumentOutOfRangeException>(() => source.CopyTo(destination, index));
|
|
}
|
|
}
|
|
}
|
|
|
|
#pragma warning restore CA1707
|
|
#pragma warning restore CA1861
|