mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-01 04:34:50 -04:00
CodingStlye: Fixing whitespaces
This commit is contained in:
parent
8ff2fe3965
commit
d3a03771dd
@ -7,6 +7,7 @@ trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
smart_tab = true
|
||||
|
||||
[{*.yaml,*.yml}]
|
||||
indent_style = space
|
||||
|
@ -6,12 +6,15 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.354" />
|
||||
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" />
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.354" PrivateAssets="All" />
|
||||
|
||||
<None Include="$(MSBuildThisFileDirectory)stylecop.json" Link="stylecop.json" Visible="false" />
|
||||
<None Include="$(MSBuildThisFileDirectory).editorconfig" Link="stylecop.json" Visible="false" />
|
||||
<None Include="$(MSBuildThisFileDirectory).editorconfig" Link=".editorconfig" Visible="false" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)Kyoo.ruleset</CodeAnalysisRuleSet>
|
||||
<!-- <AnalysisMode>AllEnabledByDefault</AnalysisMode>-->
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
using System.Runtime.InteropServices;
|
||||
|
@ -613,5 +613,5 @@ namespace Kyoo.Abstractions.Controllers
|
||||
/// <summary>
|
||||
/// A repository to handle users.
|
||||
/// </summary>
|
||||
public interface IUserRepository : IRepository<User> {}
|
||||
public interface IUserRepository : IRepository<User> { }
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ namespace Kyoo.Abstractions.Controllers
|
||||
/// <returns>A new parameter's value for this current parameter</returns>
|
||||
public TaskParameter CreateValue(object value)
|
||||
{
|
||||
return this with {Value = value};
|
||||
return this with { Value = value };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -144,7 +144,7 @@ namespace Kyoo.Abstractions.Controllers
|
||||
/// <summary>
|
||||
/// Create a new, empty, <see cref="TaskParameters"/>
|
||||
/// </summary>
|
||||
public TaskParameters() {}
|
||||
public TaskParameters() { }
|
||||
|
||||
/// <summary>
|
||||
/// Create a <see cref="TaskParameters"/> with an initial parameters content
|
||||
|
@ -1,6 +1,6 @@
|
||||
using Kyoo.Abstractions.Models;
|
||||
using System.Threading.Tasks;
|
||||
using JetBrains.Annotations;
|
||||
using Kyoo.Abstractions.Models;
|
||||
|
||||
namespace Kyoo.Abstractions.Controllers
|
||||
{
|
||||
|
@ -23,7 +23,7 @@ namespace Kyoo.Abstractions.Models.Attributes
|
||||
/// <summary>
|
||||
/// Create a new <see cref="LoadableRelationAttribute"/>.
|
||||
/// </summary>
|
||||
public LoadableRelationAttribute() {}
|
||||
public LoadableRelationAttribute() { }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="LoadableRelationAttribute"/> with a baking relationID field.
|
||||
|
@ -6,13 +6,13 @@ namespace Kyoo.Abstractions.Models.Attributes
|
||||
/// Remove an property from the serialization pipeline. It will simply be skipped.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
|
||||
public class SerializeIgnoreAttribute : Attribute {}
|
||||
public class SerializeIgnoreAttribute : Attribute { }
|
||||
|
||||
/// <summary>
|
||||
/// Remove a property from the deserialization pipeline. The user can't input value for this property.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
|
||||
public class DeserializeIgnoreAttribute : Attribute {}
|
||||
public class DeserializeIgnoreAttribute : Attribute { }
|
||||
|
||||
/// <summary>
|
||||
/// Change the way the field is serialized. It allow one to use a string format like formatting instead of the default value.
|
||||
|
@ -11,7 +11,7 @@ namespace Kyoo.Abstractions.Models
|
||||
public float StartTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The end time of the chapter (in second from the start of the episode)&.
|
||||
/// The end time of the chapter (in second from the start of the episode).
|
||||
/// </summary>
|
||||
public float EndTime { get; set; }
|
||||
|
||||
|
@ -15,7 +15,7 @@ namespace Kyoo.Abstractions.Models.Exceptions
|
||||
/// </summary>
|
||||
public TaskFailedException()
|
||||
: base("A task failed.")
|
||||
{}
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="TaskFailedException"/> with a custom message.
|
||||
@ -23,7 +23,7 @@ namespace Kyoo.Abstractions.Models.Exceptions
|
||||
/// <param name="message">The message to use.</param>
|
||||
public TaskFailedException(string message)
|
||||
: base(message)
|
||||
{}
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="TaskFailedException"/> wrapping another exception.
|
||||
@ -31,7 +31,7 @@ namespace Kyoo.Abstractions.Models.Exceptions
|
||||
/// <param name="exception">The exception to wrap.</param>
|
||||
public TaskFailedException(Exception exception)
|
||||
: base(exception)
|
||||
{}
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// The serialization constructor
|
||||
|
@ -74,7 +74,7 @@ namespace Kyoo.Abstractions.Models
|
||||
/// <summary>
|
||||
/// Create a new, empty <see cref="LibraryItem"/>.
|
||||
/// </summary>
|
||||
public LibraryItem() {}
|
||||
public LibraryItem() { }
|
||||
|
||||
/// <summary>
|
||||
/// Create a <see cref="LibraryItem"/> from a show.
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using JetBrains.Annotations;
|
||||
|
@ -28,7 +28,7 @@ namespace Kyoo.Abstractions.Models
|
||||
/// <summary>
|
||||
/// Create a new, empty <see cref="Genre"/>.
|
||||
/// </summary>
|
||||
public Genre() {}
|
||||
public Genre() { }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="Genre"/> and specify it's <see cref="Name"/>.
|
||||
|
@ -14,7 +14,8 @@ namespace Kyoo.Abstractions.Models
|
||||
/// <summary>
|
||||
/// The link to metadata providers that this show has. See <see cref="MetadataID"/> for more information.
|
||||
/// </summary>
|
||||
[EditableRelation] [LoadableRelation]
|
||||
[EditableRelation]
|
||||
[LoadableRelation]
|
||||
public ICollection<MetadataID> ExternalIDs { get; set; }
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using JetBrains.Annotations;
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
@ -46,8 +46,10 @@ namespace Kyoo.Abstractions.Models
|
||||
@"(?<ep>[^\.]+)\.(?<lang>\w{0,3})(-(?<index>\d+))?(\.(?<forced>forced))?\.(?<type>\w+)(\.\w*)?");
|
||||
|
||||
if (!match.Success)
|
||||
{
|
||||
throw new ArgumentException("Invalid track slug. " +
|
||||
"Format: {episodeSlug}.{language}[-{index}][.forced].{type}[.{extension}]");
|
||||
}
|
||||
|
||||
EpisodeSlug = match.Groups["ep"].Value;
|
||||
Language = match.Groups["lang"].Value;
|
||||
@ -137,7 +139,7 @@ namespace Kyoo.Abstractions.Models
|
||||
name += " Forced";
|
||||
if (IsExternal)
|
||||
name += " (External)";
|
||||
if (Title is {Length: > 1})
|
||||
if (Title is { Length: > 1 })
|
||||
name += " - " + Title;
|
||||
return name;
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ namespace Kyoo.Utils
|
||||
[NotNull] Type type,
|
||||
params object[] args)
|
||||
{
|
||||
return RunGenericMethod<T>(owner, methodName, new[] {type}, args);
|
||||
return RunGenericMethod<T>(owner, methodName, new[] { type }, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -361,7 +361,7 @@ namespace Kyoo.Utils
|
||||
[NotNull] Type type,
|
||||
params object[] args)
|
||||
{
|
||||
return RunGenericMethod<T>(instance, methodName, new[] {type}, args);
|
||||
return RunGenericMethod<T>(instance, methodName, new[] { type }, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
@ -70,6 +71,8 @@ namespace Kyoo.Authentication
|
||||
/// <param name="configuration">The configuration to use</param>
|
||||
/// <param name="logger">The logger used to allow IdentityServer to log things</param>
|
||||
/// <param name="environment">The environment information to check if the app runs in debug mode</param>
|
||||
[SuppressMessage("ReSharper", "ContextualLoggerProblem",
|
||||
Justification = "The logger is used for a dependency that is not created via the container.")]
|
||||
public AuthenticationModule(IConfiguration configuration,
|
||||
ILogger<DefaultCorsPolicyService> logger,
|
||||
IWebHostEnvironment environment)
|
||||
|
@ -104,7 +104,7 @@ namespace Kyoo.Authentication
|
||||
X509Certificate bouncyCert = certificateGenerator.Generate(signatureFactory);
|
||||
|
||||
Pkcs12Store store = new Pkcs12StoreBuilder().Build();
|
||||
store.SetKeyEntry("Kyoo_key", new AsymmetricKeyEntry(subjectKeyPair.Private), new []
|
||||
store.SetKeyEntry("Kyoo_key", new AsymmetricKeyEntry(subjectKeyPair.Private), new[]
|
||||
{
|
||||
new X509CertificateEntry(bouncyCert)
|
||||
});
|
||||
|
@ -37,7 +37,7 @@ namespace Kyoo.Authentication
|
||||
return new(user.ID.ToString())
|
||||
{
|
||||
DisplayName = user.Username,
|
||||
AdditionalClaims = new[] {new Claim("permissions", string.Join(',', user.Permissions))}
|
||||
AdditionalClaims = new[] { new Claim("permissions", string.Join(',', user.Permissions)) }
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -78,10 +78,10 @@ namespace Kyoo.Authentication.Views
|
||||
}
|
||||
catch (DuplicatedItemException)
|
||||
{
|
||||
return Conflict(new {Errors = new {Duplicate = new[] {"A user with this name already exists"}}});
|
||||
return Conflict(new { Errors = new { Duplicate = new[] { "A user with this name already exists" } } });
|
||||
}
|
||||
|
||||
return Ok(new {Otac = user.ExtraData["otac"]});
|
||||
return Ok(new { Otac = user.ExtraData["otac"] });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -135,7 +135,8 @@ namespace Kyoo.Authentication.Views
|
||||
{
|
||||
return BadRequest(new
|
||||
{
|
||||
code = "ExpiredOTAC", description = "The OTAC has expired. Try to login with your password."
|
||||
code = "ExpiredOTAC",
|
||||
description = "The OTAC has expired. Try to login with your password."
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ namespace Kyoo.Core.Controllers
|
||||
/// <summary>
|
||||
/// A <see cref="IFileSystem"/> for http/https links.
|
||||
/// </summary>
|
||||
[FileSystemMetadata(new [] {"http", "https"})]
|
||||
[FileSystemMetadata(new[] { "http", "https" })]
|
||||
public class HttpFileSystem : IFileSystem
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -15,7 +15,7 @@ namespace Kyoo.Core.Controllers
|
||||
/// <summary>
|
||||
/// A <see cref="IFileSystem"/> for the local filesystem (using System.IO).
|
||||
/// </summary>
|
||||
[FileSystemMetadata(new [] {"", "file"}, StripScheme = true)]
|
||||
[FileSystemMetadata(new[] { "", "file" }, StripScheme = true)]
|
||||
public class LocalFileSystem : IFileSystem
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -278,7 +278,7 @@ namespace Kyoo.Core.Controllers
|
||||
{
|
||||
MethodInfo setter = typeof(T).GetProperty(nameof(resource.Slug))!.GetSetMethod();
|
||||
if (setter != null)
|
||||
setter.Invoke(resource, new object[] {resource.Slug + '!'});
|
||||
setter.Invoke(resource, new object[] { resource.Slug + '!' });
|
||||
else
|
||||
throw new ArgumentException("Resources slug can't be number only.");
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ using Stream = Kyoo.Core.Models.Watch.Stream;
|
||||
|
||||
namespace Kyoo.Core.Controllers
|
||||
{
|
||||
public class BadTranscoderException : Exception {}
|
||||
public class BadTranscoderException : Exception { }
|
||||
|
||||
public class Transcoder : ITranscoder
|
||||
{
|
||||
|
@ -69,7 +69,7 @@ namespace Kyoo.Core.Tasks
|
||||
string argument = arguments["slug"].As<string>();
|
||||
ICollection<Library> libraries = argument == null
|
||||
? await _libraryManager.GetAll<Library>()
|
||||
: new [] { await _libraryManager.GetOrDefault<Library>(argument)};
|
||||
: new[] { await _libraryManager.GetOrDefault<Library>(argument) };
|
||||
|
||||
if (argument != null && libraries.First() == null)
|
||||
throw new ArgumentException($"No library found with the name {argument}");
|
||||
|
@ -55,7 +55,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,7 +153,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
@ -183,7 +183,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
catch (DuplicatedItemException)
|
||||
{
|
||||
|
@ -34,7 +34,7 @@ namespace Kyoo.Core.Api
|
||||
if (result.Value != null)
|
||||
_taskManager.StartTask("scan",
|
||||
new Progress<float>(),
|
||||
new Dictionary<string, object> {{"slug", result.Value.Slug}});
|
||||
new Dictionary<string, object> { { "slug", result.Value.Slug } });
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,7 +138,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
@ -164,7 +164,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
@ -190,7 +190,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,7 +110,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,7 +161,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,7 +186,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,7 +212,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
@ -238,7 +238,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
@ -292,7 +292,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
@ -318,7 +318,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
@ -344,7 +344,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
@ -370,7 +370,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ namespace Kyoo.Core.Api
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(new {Error = ex.Message});
|
||||
return BadRequest(new { Error = ex.Message });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -304,19 +304,19 @@ namespace Kyoo.Database
|
||||
.HasIndex(x => x.Slug)
|
||||
.IsUnique();
|
||||
modelBuilder.Entity<Season>()
|
||||
.HasIndex(x => new {x.ShowID, x.SeasonNumber})
|
||||
.HasIndex(x => new { x.ShowID, x.SeasonNumber })
|
||||
.IsUnique();
|
||||
modelBuilder.Entity<Season>()
|
||||
.HasIndex(x => x.Slug)
|
||||
.IsUnique();
|
||||
modelBuilder.Entity<Episode>()
|
||||
.HasIndex(x => new {x.ShowID, x.SeasonNumber, x.EpisodeNumber, x.AbsoluteNumber})
|
||||
.HasIndex(x => new { x.ShowID, x.SeasonNumber, x.EpisodeNumber, x.AbsoluteNumber })
|
||||
.IsUnique();
|
||||
modelBuilder.Entity<Episode>()
|
||||
.HasIndex(x => x.Slug)
|
||||
.IsUnique();
|
||||
modelBuilder.Entity<Track>()
|
||||
.HasIndex(x => new {x.EpisodeID, x.Type, x.Language, x.TrackIndex, x.IsForced})
|
||||
.HasIndex(x => new { x.EpisodeID, x.Type, x.Language, x.TrackIndex, x.IsForced })
|
||||
.IsUnique();
|
||||
modelBuilder.Entity<Track>()
|
||||
.HasIndex(x => x.Slug)
|
||||
|
@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
@ -6,7 +6,6 @@
|
||||
<RootNamespace>Kyoo.Database</RootNamespace>
|
||||
<Authors>Zoe Roux</Authors>
|
||||
<RepositoryUrl>https://github.com/AnonymusRaccoon/Kyoo</RepositoryUrl>
|
||||
<OutputType>Library</OutputType>
|
||||
<LangVersion>default</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
|
@ -155,7 +155,7 @@ namespace Kyoo.Postgresql
|
||||
/// <inheritdoc />
|
||||
protected override bool IsDuplicateException(Exception ex)
|
||||
{
|
||||
return ex.InnerException is PostgresException {SqlState: PostgresErrorCodes.UniqueViolation};
|
||||
return ex.InnerException is PostgresException { SqlState: PostgresErrorCodes.UniqueViolation };
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
@ -32,7 +32,7 @@ namespace Kyoo.TheMovieDb
|
||||
? $"https://image.tmdb.org/t/p/original{collection.BackdropPath}"
|
||||
: null
|
||||
},
|
||||
ExternalIDs = new []
|
||||
ExternalIDs = new[]
|
||||
{
|
||||
new MetadataID
|
||||
{
|
||||
@ -65,7 +65,7 @@ namespace Kyoo.TheMovieDb
|
||||
? $"https://image.tmdb.org/t/p/original{collection.BackdropPath}"
|
||||
: null
|
||||
},
|
||||
ExternalIDs = new []
|
||||
ExternalIDs = new[]
|
||||
{
|
||||
new MetadataID
|
||||
{
|
||||
|
@ -31,7 +31,7 @@ namespace Kyoo.TheMovieDb
|
||||
? $"https://image.tmdb.org/t/p/original{episode.StillPath}"
|
||||
: null
|
||||
},
|
||||
ExternalIDs = new []
|
||||
ExternalIDs = new[]
|
||||
{
|
||||
new MetadataID
|
||||
{
|
||||
|
@ -50,7 +50,7 @@ namespace Kyoo.TheMovieDb
|
||||
.Select(x => x.ToPeople(provider))
|
||||
.Concat(movie.Credits.Crew.Select(x => x.ToPeople(provider)))
|
||||
.ToArray(),
|
||||
ExternalIDs = new []
|
||||
ExternalIDs = new[]
|
||||
{
|
||||
new MetadataID
|
||||
{
|
||||
@ -87,7 +87,7 @@ namespace Kyoo.TheMovieDb
|
||||
: null,
|
||||
},
|
||||
IsMovie = true,
|
||||
ExternalIDs = new []
|
||||
ExternalIDs = new[]
|
||||
{
|
||||
new MetadataID
|
||||
{
|
||||
|
@ -30,7 +30,7 @@ namespace Kyoo.TheMovieDb
|
||||
? $"https://image.tmdb.org/t/p/original{season.PosterPath}"
|
||||
: null
|
||||
},
|
||||
ExternalIDs = new []
|
||||
ExternalIDs = new[]
|
||||
{
|
||||
new MetadataID
|
||||
{
|
||||
|
@ -110,8 +110,8 @@ namespace Kyoo.TheTvdb
|
||||
if (!int.TryParse(episode.Show?.GetID(Provider.Slug), out int id))
|
||||
return null;
|
||||
EpisodeQuery query = episode.AbsoluteNumber != null
|
||||
? new EpisodeQuery {AbsoluteNumber = episode.AbsoluteNumber}
|
||||
: new EpisodeQuery {AiredSeason = episode.SeasonNumber, AiredEpisode = episode.EpisodeNumber};
|
||||
? new EpisodeQuery { AbsoluteNumber = episode.AbsoluteNumber }
|
||||
: new EpisodeQuery { AiredSeason = episode.SeasonNumber, AiredEpisode = episode.EpisodeNumber };
|
||||
TvDbResponse<EpisodeRecord[]> episodes = await _client.Series.GetEpisodesAsync(id, 0, query);
|
||||
return episodes.Data.FirstOrDefault()?.ToEpisode(Provider);
|
||||
}
|
||||
|
@ -41,9 +41,11 @@ namespace Kyoo.WebApp
|
||||
public WebAppModule(ILogger<WebAppModule> logger)
|
||||
{
|
||||
if (!Enabled)
|
||||
{
|
||||
logger.LogError("The web app files could not be found, it will be disabled. " +
|
||||
"If you cloned the project, you probably forgot to use the --recurse flag");
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Configure(IServiceCollection services)
|
||||
|
@ -10,10 +10,15 @@
|
||||
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.CSharp.ReadabilityRules">
|
||||
<Rule Id="SA1101" Action="None" /> <!-- PrefixLocalCallsWithThis -->
|
||||
<Rule Id="SX1101" Action="Warning" /> <!-- DoNotPrefixLocalMembersWithThis -->
|
||||
<Rule Id="SA1134" Action="None" /> <!-- AttributesMustNotShareLine -->
|
||||
</Rules>
|
||||
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.CSharp.SpacingRules">
|
||||
<Rule Id="SA1502" Action="None"/> <!-- DocumentationLinesMustBeginWithSingleSpace -->
|
||||
</Rules>
|
||||
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.CSharp.LayoutRules">
|
||||
<Rule Id="SA1503" Action="None"/> <!-- BracesMustNotBeOmitted -->
|
||||
<Rule Id="SA1520" Action="None"/> <!-- UseBracesConsistently -->
|
||||
</Rules>
|
||||
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.CSharp.DocumentationRules">
|
||||
<Rule Id="SA1642" Action="None" /> <!-- ConstructorSummaryDocumentationMustBeginWithStandardText -->
|
||||
<Rule Id="SA1643" Action="None" /> <!-- DestructorSummaryDocumentationMustBeginWithStandardText -->
|
||||
|
@ -131,7 +131,7 @@ namespace Kyoo.Tests
|
||||
[Fact]
|
||||
public async Task EditNonExistingTest()
|
||||
{
|
||||
await Assert.ThrowsAsync<ItemNotFoundException>(() => _repository.Edit(new T {ID = 56}, false));
|
||||
await Assert.ThrowsAsync<ItemNotFoundException>(() => _repository.Edit(new T { ID = 56 }, false));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -90,7 +90,7 @@ namespace Kyoo.Tests.Database
|
||||
public async Task EditTest()
|
||||
{
|
||||
Library value = await _repository.Get(TestSample.Get<Library>().Slug);
|
||||
value.Paths = new [] {"/super", "/test"};
|
||||
value.Paths = new[] { "/super", "/test" };
|
||||
value.Name = "New Title";
|
||||
Library edited = await _repository.Edit(value, false);
|
||||
|
||||
@ -150,7 +150,7 @@ namespace Kyoo.Tests.Database
|
||||
{
|
||||
Slug = "super-test",
|
||||
Name = "This is a test title",
|
||||
Paths = new [] {"path"}
|
||||
Paths = new[] { "path" }
|
||||
};
|
||||
await _repository.Create(value);
|
||||
ICollection<Library> ret = await _repository.Search(query);
|
||||
|
@ -61,11 +61,11 @@ namespace Kyoo.Tests.Database
|
||||
public async Task EditGenreTest()
|
||||
{
|
||||
Show value = await _repository.Get(TestSample.Get<Show>().Slug);
|
||||
value.Genres = new[] {new Genre("test")};
|
||||
value.Genres = new[] { new Genre("test") };
|
||||
Show edited = await _repository.Edit(value, false);
|
||||
|
||||
Assert.Equal(value.Slug, edited.Slug);
|
||||
Assert.Equal(value.Genres.Select(x => new{x.Slug, x.Name}), edited.Genres.Select(x => new{x.Slug, x.Name}));
|
||||
Assert.Equal(value.Genres.Select(x => new { x.Slug, x.Name }), edited.Genres.Select(x => new { x.Slug, x.Name }));
|
||||
|
||||
await using DatabaseContext database = Repositories.Context.New();
|
||||
Show show = await database.Shows
|
||||
@ -73,7 +73,7 @@ namespace Kyoo.Tests.Database
|
||||
.FirstAsync();
|
||||
|
||||
Assert.Equal(value.Slug, show.Slug);
|
||||
Assert.Equal(value.Genres.Select(x => new{x.Slug, x.Name}), show.Genres.Select(x => new{x.Slug, x.Name}));
|
||||
Assert.Equal(value.Genres.Select(x => new { x.Slug, x.Name }), show.Genres.Select(x => new { x.Slug, x.Name }));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -85,7 +85,7 @@ namespace Kyoo.Tests.Database
|
||||
Show edited = await _repository.Edit(value, false);
|
||||
|
||||
Assert.Equal(value.Slug, edited.Slug);
|
||||
Assert.Equal(value.Genres.Select(x => new{x.Slug, x.Name}), edited.Genres.Select(x => new{x.Slug, x.Name}));
|
||||
Assert.Equal(value.Genres.Select(x => new { x.Slug, x.Name }), edited.Genres.Select(x => new { x.Slug, x.Name }));
|
||||
|
||||
await using DatabaseContext database = Repositories.Context.New();
|
||||
Show show = await database.Shows
|
||||
@ -93,7 +93,7 @@ namespace Kyoo.Tests.Database
|
||||
.FirstAsync();
|
||||
|
||||
Assert.Equal(value.Slug, show.Slug);
|
||||
Assert.Equal(value.Genres.Select(x => new{x.Slug, x.Name}), show.Genres.Select(x => new{x.Slug, x.Name}));
|
||||
Assert.Equal(value.Genres.Select(x => new { x.Slug, x.Name }), show.Genres.Select(x => new { x.Slug, x.Name }));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -119,7 +119,7 @@ namespace Kyoo.Tests.Database
|
||||
public async Task EditAliasesTest()
|
||||
{
|
||||
Show value = await _repository.Get(TestSample.Get<Show>().Slug);
|
||||
value.Aliases = new[] {"NiceNewAlias", "SecondAlias"};
|
||||
value.Aliases = new[] { "NiceNewAlias", "SecondAlias" };
|
||||
Show edited = await _repository.Edit(value, false);
|
||||
|
||||
Assert.Equal(value.Slug, edited.Slug);
|
||||
@ -152,8 +152,8 @@ namespace Kyoo.Tests.Database
|
||||
Assert.Equal(value.Slug, edited.Slug);
|
||||
Assert.Equal(edited.People.First().ShowID, value.ID);
|
||||
Assert.Equal(
|
||||
value.People.Select(x => new{x.Role, x.Slug, x.People.Name}),
|
||||
edited.People.Select(x => new{x.Role, x.Slug, x.People.Name}));
|
||||
value.People.Select(x => new { x.Role, x.Slug, x.People.Name }),
|
||||
edited.People.Select(x => new { x.Role, x.Slug, x.People.Name }));
|
||||
|
||||
await using DatabaseContext database = Repositories.Context.New();
|
||||
Show show = await database.Shows
|
||||
@ -163,8 +163,8 @@ namespace Kyoo.Tests.Database
|
||||
|
||||
Assert.Equal(value.Slug, show.Slug);
|
||||
Assert.Equal(
|
||||
value.People.Select(x => new{x.Role, x.Slug, x.People.Name}),
|
||||
show.People.Select(x => new{x.Role, x.Slug, x.People.Name}));
|
||||
value.People.Select(x => new { x.Role, x.Slug, x.People.Name }),
|
||||
show.People.Select(x => new { x.Role, x.Slug, x.People.Name }));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -183,8 +183,8 @@ namespace Kyoo.Tests.Database
|
||||
|
||||
Assert.Equal(value.Slug, edited.Slug);
|
||||
Assert.Equal(
|
||||
value.ExternalIDs.Select(x => new {x.DataID, x.Provider.Slug}),
|
||||
edited.ExternalIDs.Select(x => new {x.DataID, x.Provider.Slug}));
|
||||
value.ExternalIDs.Select(x => new { x.DataID, x.Provider.Slug }),
|
||||
edited.ExternalIDs.Select(x => new { x.DataID, x.Provider.Slug }));
|
||||
|
||||
await using DatabaseContext database = Repositories.Context.New();
|
||||
Show show = await database.Shows
|
||||
@ -194,8 +194,8 @@ namespace Kyoo.Tests.Database
|
||||
|
||||
Assert.Equal(value.Slug, show.Slug);
|
||||
Assert.Equal(
|
||||
value.ExternalIDs.Select(x => new {x.DataID, x.Provider.Slug}),
|
||||
show.ExternalIDs.Select(x => new {x.DataID, x.Provider.Slug}));
|
||||
value.ExternalIDs.Select(x => new { x.DataID, x.Provider.Slug }),
|
||||
show.ExternalIDs.Select(x => new { x.DataID, x.Provider.Slug }));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -63,7 +63,7 @@ namespace Kyoo.Tests
|
||||
|
||||
[CollectionDefinition(nameof(Postgresql))]
|
||||
public class PostgresCollection : ICollectionFixture<PostgresFixture>
|
||||
{}
|
||||
{ }
|
||||
|
||||
public sealed class PostgresFixture : IDisposable
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ namespace Kyoo.Tests
|
||||
ID = 2,
|
||||
Slug = "new-library",
|
||||
Name = "New Library",
|
||||
Paths = new [] {"/a/random/path"}
|
||||
Paths = new[] { "/a/random/path" }
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -132,7 +132,7 @@ namespace Kyoo.Tests
|
||||
ID = 1,
|
||||
Slug = "deck",
|
||||
Name = "Deck",
|
||||
Paths = new[] {"/path/to/deck"}
|
||||
Paths = new[] { "/path/to/deck" }
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -297,7 +297,7 @@ namespace Kyoo.Tests
|
||||
Username = "User",
|
||||
Email = "user@im-a-user.com",
|
||||
Password = "MD5-encoded",
|
||||
Permissions = new [] {"overall.read"}
|
||||
Permissions = new[] { "overall.read" }
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -345,12 +345,12 @@ namespace Kyoo.Tests
|
||||
|
||||
Studio studio = Get<Studio>();
|
||||
studio.ID = 0;
|
||||
studio.Shows = new List<Show> {show};
|
||||
studio.Shows = new List<Show> { show };
|
||||
context.Studios.Add(studio);
|
||||
|
||||
Genre genre = Get<Genre>();
|
||||
genre.ID = 0;
|
||||
genre.Shows = new List<Show> {show};
|
||||
genre.Shows = new List<Show> { show };
|
||||
context.Genres.Add(genre);
|
||||
|
||||
People people = Get<People>();
|
||||
@ -363,8 +363,8 @@ namespace Kyoo.Tests
|
||||
|
||||
Library library = Get<Library>();
|
||||
library.ID = 0;
|
||||
library.Collections = new List<Collection> {collection};
|
||||
library.Providers = new List<Provider> {provider};
|
||||
library.Collections = new List<Collection> { collection };
|
||||
library.Providers = new List<Provider> { provider };
|
||||
context.Libraries.Add(library);
|
||||
|
||||
User user = Get<User>();
|
||||
|
@ -20,7 +20,7 @@ namespace Kyoo.Tests.Identifier
|
||||
Mock<IOptionsMonitor<MediaOptions>> options = new();
|
||||
options.Setup(x => x.CurrentValue).Returns(new MediaOptions
|
||||
{
|
||||
Regex = new []
|
||||
Regex = new[]
|
||||
{
|
||||
"^\\/?(?<Collection>.+)?\\/(?<Show>.+?)(?: \\((?<StartYear>\\d+)\\))?\\/\\k<Show>(?: \\(\\d+\\))? S(?<Season>\\d+)E(?<Episode>\\d+)\\..*$",
|
||||
"^\\/?(?<Collection>.+)?\\/(?<Show>.+?)(?: \\((?<StartYear>\\d+)\\))?\\/\\k<Show>(?: \\(\\d+\\))? (?<Absolute>\\d+)\\..*$",
|
||||
|
@ -60,9 +60,9 @@ namespace Kyoo.Tests.Identifier
|
||||
mock.Setup(x => x.Get(show)).ReturnsAsync(new Show
|
||||
{
|
||||
Title = "title",
|
||||
Genres = new[] { new Genre("ToMerge")}
|
||||
Genres = new[] { new Genre("ToMerge") }
|
||||
});
|
||||
AProviderComposite provider = new ProviderComposite(new []
|
||||
AProviderComposite provider = new ProviderComposite(new[]
|
||||
{
|
||||
mock.Object
|
||||
},
|
||||
@ -89,7 +89,7 @@ namespace Kyoo.Tests.Identifier
|
||||
mock.Setup(x => x.Get(show)).ReturnsAsync(new Show
|
||||
{
|
||||
Title = "title",
|
||||
Genres = new[] { new Genre("ToMerge")}
|
||||
Genres = new[] { new Genre("ToMerge") }
|
||||
});
|
||||
|
||||
Mock<IMetadataProvider> mockTwo = new();
|
||||
@ -98,14 +98,14 @@ namespace Kyoo.Tests.Identifier
|
||||
{
|
||||
Title = "title2",
|
||||
Status = Status.Finished,
|
||||
Genres = new[] { new Genre("ToMerge")}
|
||||
Genres = new[] { new Genre("ToMerge") }
|
||||
});
|
||||
|
||||
Mock<IMetadataProvider> mockFailing = new();
|
||||
mockFailing.Setup(x => x.Provider).Returns(new Provider("mockFail", ""));
|
||||
mockFailing.Setup(x => x.Get(show)).Throws<ArgumentException>();
|
||||
|
||||
AProviderComposite provider = new ProviderComposite(new []
|
||||
AProviderComposite provider = new ProviderComposite(new[]
|
||||
{
|
||||
mock.Object,
|
||||
mockTwo.Object,
|
||||
|
@ -85,7 +85,7 @@ namespace Kyoo.Tests.Identifier.Tvdb
|
||||
Poster = "poster",
|
||||
FanArt = "fanart",
|
||||
Id = 5,
|
||||
Genre = new []
|
||||
Genre = new[]
|
||||
{
|
||||
"Action",
|
||||
"Test With Spéàacial characters"
|
||||
|
@ -12,7 +12,7 @@ namespace Kyoo.Tests.Utility
|
||||
[Fact]
|
||||
public void MapTest()
|
||||
{
|
||||
int[] list = {1, 2, 3, 4};
|
||||
int[] list = { 1, 2, 3, 4 };
|
||||
Assert.All(list.Map((x, i) => (x, i)), x => Assert.Equal(x.x - 1, x.i));
|
||||
Assert.Throws<ArgumentNullException>(() => list.Map(((Func<int, int, int>)null)!));
|
||||
list = null;
|
||||
@ -22,8 +22,8 @@ namespace Kyoo.Tests.Utility
|
||||
[Fact]
|
||||
public async Task MapAsyncTest()
|
||||
{
|
||||
int[] list = {1, 2, 3, 4};
|
||||
await foreach((int x, int i) in list.MapAsync((x, i) => Task.FromResult((x, i))))
|
||||
int[] list = { 1, 2, 3, 4 };
|
||||
await foreach ((int x, int i) in list.MapAsync((x, i) => Task.FromResult((x, i))))
|
||||
{
|
||||
Assert.Equal(x - 1, i);
|
||||
}
|
||||
@ -35,9 +35,9 @@ namespace Kyoo.Tests.Utility
|
||||
[Fact]
|
||||
public async Task SelectAsyncTest()
|
||||
{
|
||||
int[] list = {1, 2, 3, 4};
|
||||
int[] list = { 1, 2, 3, 4 };
|
||||
int i = 2;
|
||||
await foreach(int x in list.SelectAsync(x => Task.FromResult(x + 1)))
|
||||
await foreach (int x in list.SelectAsync(x => Task.FromResult(x + 1)))
|
||||
{
|
||||
Assert.Equal(i++, x);
|
||||
}
|
||||
@ -49,7 +49,7 @@ namespace Kyoo.Tests.Utility
|
||||
[Fact]
|
||||
public async Task ToListAsyncTest()
|
||||
{
|
||||
int[] expected = {1, 2, 3, 4};
|
||||
int[] expected = { 1, 2, 3, 4 };
|
||||
IAsyncEnumerable<int> list = expected.SelectAsync(Task.FromResult);
|
||||
Assert.Equal(expected, await list.ToListAsync());
|
||||
list = null;
|
||||
@ -59,14 +59,14 @@ namespace Kyoo.Tests.Utility
|
||||
[Fact]
|
||||
public void IfEmptyTest()
|
||||
{
|
||||
int[] list = {1, 2, 3, 4};
|
||||
int[] list = { 1, 2, 3, 4 };
|
||||
list = list.IfEmpty(() => KAssert.Fail("Empty action should not be triggered.")).ToArray();
|
||||
Assert.Throws<ArgumentNullException>(() => list.IfEmpty(null!).ToList());
|
||||
list = null;
|
||||
Assert.Throws<ArgumentNullException>(() => list!.IfEmpty(() => {}).ToList());
|
||||
Assert.Throws<ArgumentNullException>(() => list!.IfEmpty(() => { }).ToList());
|
||||
list = Array.Empty<int>();
|
||||
Assert.Throws<ArgumentException>(() => list.IfEmpty(() => throw new ArgumentException()).ToList());
|
||||
Assert.Empty(list.IfEmpty(() => {}));
|
||||
Assert.Empty(list.IfEmpty(() => { }));
|
||||
}
|
||||
}
|
||||
}
|
@ -95,11 +95,11 @@ namespace Kyoo.Tests.Utility
|
||||
Test test = new()
|
||||
{
|
||||
ID = 5,
|
||||
Numbers = new [] { 1 }
|
||||
Numbers = new[] { 1 }
|
||||
};
|
||||
Test test2 = new()
|
||||
{
|
||||
Numbers = new [] { 3 }
|
||||
Numbers = new[] { 3 }
|
||||
};
|
||||
Test ret = Merger.Merge(test, test2);
|
||||
Assert.True(ReferenceEquals(test, ret));
|
||||
@ -116,11 +116,11 @@ namespace Kyoo.Tests.Utility
|
||||
Test test = new()
|
||||
{
|
||||
ID = 5,
|
||||
Numbers = new [] { 1 }
|
||||
Numbers = new[] { 1 }
|
||||
};
|
||||
Test test2 = new()
|
||||
{
|
||||
Numbers = new []
|
||||
Numbers = new[]
|
||||
{
|
||||
1,
|
||||
3,
|
||||
@ -206,11 +206,11 @@ namespace Kyoo.Tests.Utility
|
||||
Show test = new()
|
||||
{
|
||||
ID = 5,
|
||||
Genres = new [] { new Genre("test") }
|
||||
Genres = new[] { new Genre("test") }
|
||||
};
|
||||
Show test2 = new()
|
||||
{
|
||||
Genres = new []
|
||||
Genres = new[]
|
||||
{
|
||||
new Genre("test"),
|
||||
new Genre("test2")
|
||||
@ -410,7 +410,8 @@ namespace Kyoo.Tests.Utility
|
||||
{
|
||||
public Dictionary<int, int> Backing;
|
||||
|
||||
[UsedImplicitly] public Dictionary<int, int> Dictionary
|
||||
[UsedImplicitly]
|
||||
public Dictionary<int, int> Dictionary
|
||||
{
|
||||
get => Backing;
|
||||
set
|
||||
|
@ -21,7 +21,7 @@ namespace Kyoo.Tests.Utility
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => Task.FromResult(1)
|
||||
.Then(_ => throw new ArgumentException()));
|
||||
Assert.Equal(1, await Task.FromResult(1)
|
||||
.Then(_ => {}));
|
||||
.Then(_ => { }));
|
||||
|
||||
static async Task<int> Faulted()
|
||||
{
|
||||
@ -39,7 +39,7 @@ namespace Kyoo.Tests.Utility
|
||||
CancellationTokenSource token = new();
|
||||
token.Cancel();
|
||||
await Assert.ThrowsAsync<TaskCanceledException>(() => Task.Run(Infinite, token.Token)
|
||||
.Then(_ => {}));
|
||||
.Then(_ => { }));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -53,7 +53,7 @@ namespace Kyoo.Tests.Utility
|
||||
Assert.Throws<ArgumentException>(() => KUtility.GetMethod(typeof(UtilityTests),
|
||||
BindingFlags.Instance | BindingFlags.Public,
|
||||
nameof(GetMethodTest),
|
||||
new [] { typeof(KUtility) },
|
||||
new[] { typeof(KUtility) },
|
||||
Array.Empty<object>()));
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ namespace Kyoo.Tests.Utility
|
||||
MethodInfo method = KUtility.GetMethod(typeof(Merger),
|
||||
BindingFlags.Static | BindingFlags.Public,
|
||||
nameof(Merger.MergeLists),
|
||||
new [] { typeof(string) },
|
||||
new[] { typeof(string) },
|
||||
new object[] { "string", "string2", null });
|
||||
Assert.Equal(nameof(Merger.MergeLists), method.Name);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user