From 2f8d15ed08015e58fea0842fea9591111b823a9c Mon Sep 17 00:00:00 2001 From: Luca Benini Date: Sat, 13 Feb 2021 19:40:15 +0100 Subject: Moved test to Jellyfin.Server.Implementation.Tests as by review Aligned code base to review comments: Jellyfin.Server.Implementation.Tests is the correct place --- .../BaseItem/BaseItemKindTests.cs | 62 ++++++++++++++++++++++ tests/Jellyfin.Server.Tests/BaseItemKindTests.cs | 62 ---------------------- .../Jellyfin.Server.Tests.csproj | 48 ----------------- 3 files changed, 62 insertions(+), 110 deletions(-) create mode 100644 tests/Jellyfin.Server.Implementations.Tests/BaseItem/BaseItemKindTests.cs delete mode 100644 tests/Jellyfin.Server.Tests/BaseItemKindTests.cs delete mode 100644 tests/Jellyfin.Server.Tests/Jellyfin.Server.Tests.csproj (limited to 'tests') diff --git a/tests/Jellyfin.Server.Implementations.Tests/BaseItem/BaseItemKindTests.cs b/tests/Jellyfin.Server.Implementations.Tests/BaseItem/BaseItemKindTests.cs new file mode 100644 index 000000000..3f56c82f4 --- /dev/null +++ b/tests/Jellyfin.Server.Implementations.Tests/BaseItem/BaseItemKindTests.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using MediaBrowser.Controller.Entities; +using Xunit; + +namespace Jellyfin.Server.Implementations.Tests.BaseItem +{ + public class BaseItemKindTests + { + [Theory] + [ClassData(typeof(GetBaseItemDescendant))] + public void BaseKindEnumTest(Type baseItemDescendantType) + { + var defaultConstructor = baseItemDescendantType.GetConstructor(Type.EmptyTypes); + + Assert.NotNull(defaultConstructor); + if (defaultConstructor != null) + { + var instance = (MediaBrowser.Controller.Entities.BaseItem)defaultConstructor.Invoke(null); + var exception = Record.Exception(() => instance.GetBaseItemKind()); + Assert.Null(exception); + } + } + + private static bool IsProjectAssemblyName(string? name) + { + if (name == null) + { + return false; + } + + return name.Contains("Jellyfin", StringComparison.InvariantCulture) + || name.Contains("Emby", StringComparison.InvariantCulture) + || name.Contains("MediaBrowser", StringComparison.InvariantCulture) + || name.Contains("RSSDP", StringComparison.InvariantCulture); + } + + private class GetBaseItemDescendant : IEnumerable + { + public IEnumerator GetEnumerator() + { + var projectAssemblies = AppDomain.CurrentDomain.GetAssemblies() + .Where(x => IsProjectAssemblyName(x.FullName)); + + foreach (var projectAssembly in projectAssemblies) + { + var baseItemDescendantTypes = projectAssembly.GetTypes() + .Where(targetType => targetType.IsClass && !targetType.IsAbstract && targetType.IsSubclassOf(typeof(MediaBrowser.Controller.Entities.BaseItem))); + + foreach (var descendantType in baseItemDescendantTypes) + { + yield return new object?[] { descendantType }; + } + } + } + + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + } + } +} diff --git a/tests/Jellyfin.Server.Tests/BaseItemKindTests.cs b/tests/Jellyfin.Server.Tests/BaseItemKindTests.cs deleted file mode 100644 index 282760bf9..000000000 --- a/tests/Jellyfin.Server.Tests/BaseItemKindTests.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using MediaBrowser.Controller.Entities; -using Xunit; - -namespace Jellyfin.Server.Tests -{ - public class BaseItemKindTests - { - [Theory] - [ClassData(typeof(GetBaseItemDescendant))] - public void BaseKindEnumTest(Type baseItemDescendantType) - { - var defaultConstructor = baseItemDescendantType.GetConstructor(Type.EmptyTypes); - - Assert.NotNull(defaultConstructor); - if (defaultConstructor != null) - { - var instance = (BaseItem)defaultConstructor.Invoke(null); - var exception = Record.Exception(() => instance.GetBaseItemKind()); - Assert.Null(exception); - } - } - - private static bool IsProjectAssemblyName(string? name) - { - if (name == null) - { - return false; - } - - return name.Contains("Jellyfin", StringComparison.InvariantCulture) - || name.Contains("Emby", StringComparison.InvariantCulture) - || name.Contains("MediaBrowser", StringComparison.InvariantCulture) - || name.Contains("RSSDP", StringComparison.InvariantCulture); - } - - private class GetBaseItemDescendant : IEnumerable - { - public IEnumerator GetEnumerator() - { - var projectAssemblies = AppDomain.CurrentDomain.GetAssemblies() - .Where(x => IsProjectAssemblyName(x.FullName)); - - foreach (var projectAssembly in projectAssemblies) - { - var baseItemDescendantTypes = projectAssembly.GetTypes() - .Where(targetType => targetType.IsClass && !targetType.IsAbstract && targetType.IsSubclassOf(typeof(BaseItem))); - - foreach (var descendantType in baseItemDescendantTypes) - { - yield return new object?[] { descendantType }; - } - } - } - - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); - } - } -} diff --git a/tests/Jellyfin.Server.Tests/Jellyfin.Server.Tests.csproj b/tests/Jellyfin.Server.Tests/Jellyfin.Server.Tests.csproj deleted file mode 100644 index 55f600502..000000000 --- a/tests/Jellyfin.Server.Tests/Jellyfin.Server.Tests.csproj +++ /dev/null @@ -1,48 +0,0 @@ - - - - - {0FD15BDA-FA63-4FFF-9E6B-781F20DA88D9} - - - - net5.0 - false - true - enable - Jellyfin.Server.Tests - - - - - PreserveNewest - - - - - - - - - - - - - - - - - - - - - - - - - - - ../jellyfin-tests.ruleset - - - -- cgit v1.2.3