Skip to content

Commit

Permalink
chore: reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
DevYukine committed Sep 1, 2023
1 parent 1c498a5 commit aaeab64
Show file tree
Hide file tree
Showing 53 changed files with 398 additions and 383 deletions.
2 changes: 1 addition & 1 deletion Submarine.Api/Controllers/ReleaseController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public ReleaseController(ILogger<ReleaseController> logger,
}

[HttpGet]
public Task<IActionResult> GetAsync([FromQuery, Required] string title, [FromQuery, Required] Protocol protocol)
public Task<IActionResult> GetAsync([FromQuery] [Required] string title, [FromQuery] [Required] Protocol protocol)
{
try
{
Expand Down
5 changes: 3 additions & 2 deletions Submarine.Api/Models/Database/PostgresDatabaseContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ namespace Submarine.Api.Models.Database;
public class PostgresDatabaseContext : SubmarineDatabaseContext
{
private readonly IConfiguration _configuration;

public PostgresDatabaseContext(DbContextOptions options, IConfiguration configuration) : base(options, configuration)

public PostgresDatabaseContext(DbContextOptions options, IConfiguration configuration) : base(options,
configuration)
=> _configuration = configuration;

protected override void OnConfiguring(DbContextOptionsBuilder options)
Expand Down
18 changes: 9 additions & 9 deletions Submarine.Api/Models/Database/SubmarineDatabaseContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,21 @@
namespace Submarine.Api.Models.Database;

/// <summary>
/// Submarine Database Context
/// Submarine Database Context
/// </summary>
public class SubmarineDatabaseContext : DbContext
{
public DbSet<Provider> Providers { get; set; }

/// <summary>
/// Configuration of this Database Context
/// Configuration of this Database Context
/// </summary>
protected readonly IConfiguration Configuration;


public DbSet<Provider> Providers { get; set; }

/// <inheritdoc />
public SubmarineDatabaseContext(DbContextOptions options, IConfiguration configuration) : base(options)
=> Configuration = configuration;

protected override void OnModelCreating(ModelBuilder builder)
{
builder.Entity<BittorrentTracker>();
Expand All @@ -24,10 +28,6 @@ protected override void OnModelCreating(ModelBuilder builder)
base.OnModelCreating(builder);
}

/// <inheritdoc />
public SubmarineDatabaseContext(DbContextOptions options, IConfiguration configuration) : base(options)
=> Configuration = configuration;

/// <inheritdoc />
public override Task<int> SaveChangesAsync(CancellationToken cancellationToken = new())
{
Expand Down
2 changes: 1 addition & 1 deletion Submarine.Api/Repository/IProviderRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Submarine.Api.Repository;

/// <summary>
/// Provider Repository abstraction
/// Provider Repository abstraction
/// </summary>
public interface IProviderRepository : IRepositoryBase<Provider>
{
Expand Down
22 changes: 11 additions & 11 deletions Submarine.Api/Repository/IRepositoryBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,68 +3,68 @@
namespace Submarine.Api.Repository;

/// <summary>
/// Base Repository abstraction
/// Base Repository abstraction
/// </summary>
/// <typeparam name="T">Entity Type</typeparam>
public interface IRepositoryBase<T>
{
/// <summary>
/// Finds all entities in this Repository
/// Finds all entities in this Repository
/// </summary>
/// <returns>List of entities</returns>
Task<List<T>> FindAllAsync();

/// <summary>
/// Finds entities by condition
/// Finds entities by condition
/// </summary>
/// <param name="expression">condition of entities to find</param>
/// <returns>List of matching entities</returns>
Task<List<T>> FindByConditionAsync(Expression<Func<T, bool>> expression);

/// <summary>
/// Finds first entity matching condition
/// Finds first entity matching condition
/// </summary>
/// <param name="expression">condition of entity to find</param>
/// <returns>Entity matching condition if found</returns>
Task<T?> FirstByConditionAsync(Expression<Func<T, bool>> expression);

/// <summary>
/// Creates an entity in the Database
/// Creates an entity in the Database
/// </summary>
/// <param name="entity">entity to create</param>
/// <returns>created entity</returns>
Task<T> CreateAsync(T entity);

/// <summary>
/// Creates collection of entities in the Database
/// Creates collection of entities in the Database
/// </summary>
/// <param name="entities">entities to create</param>
/// <returns>collection of created entities</returns>
Task<ICollection<T>> CreateAsync(ICollection<T> entities);

/// <summary>
/// Updates an entity in the Database
/// Updates an entity in the Database
/// </summary>
/// <param name="entity">entity to update</param>
/// <returns>updated entity</returns>
Task UpdateAsync(T entity);

/// <summary>
/// Updates enumerable of entities in the Database
/// Updates enumerable of entities in the Database
/// </summary>
/// <param name="entities">entities to update</param>
/// <returns></returns>
Task UpdateAsync(IEnumerable<T> entities);

/// <summary>
/// Deletes entity from the Database
/// Deletes entity from the Database
/// </summary>
/// <param name="entity">entity to delete</param>
/// <returns></returns>
Task DeleteAsync(T entity);

/// <summary>
/// Deletes enumerable of entities from the Database
/// Deletes enumerable of entities from the Database
/// </summary>
/// <param name="entities">entities to delete</param>
/// <returns></returns>
Expand Down
4 changes: 2 additions & 2 deletions Submarine.Api/Repository/ProviderRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
namespace Submarine.Api.Repository;

/// <summary>
/// Provider Repository implementation
/// Provider Repository implementation
/// </summary>
public class ProviderRepository : RepositoryBase<Provider>, IProviderRepository
{
/// <summary>
/// Creates a new instance of <see cref="ProviderRepository"/>
/// Creates a new instance of <see cref="ProviderRepository" />
/// </summary>
/// <param name="databaseContext">Database Context</param>
public ProviderRepository(SubmarineDatabaseContext databaseContext) : base(databaseContext)
Expand Down
8 changes: 4 additions & 4 deletions Submarine.Api/Repository/RepositoryBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
namespace Submarine.Api.Repository;

/// <summary>
/// Repository Base implementation
/// Repository Base implementation
/// </summary>
/// <typeparam name="T">Entity Type</typeparam>
public abstract class RepositoryBase<T> : IRepositoryBase<T> where T : class
{
/// <summary>
/// Database Context of this Repository
/// Database Context of this Repository
/// </summary>
protected SubmarineDatabaseContext DatabaseContext { get; }

private DbSet<T> Set
=> DatabaseContext.Set<T>();

/// <summary>
/// Creates a new instance of <see cref="RepositoryBase{T}"/>
/// Creates a new instance of <see cref="RepositoryBase{T}" />
/// </summary>
/// <param name="databaseContext">database context</param>
protected RepositoryBase(SubmarineDatabaseContext databaseContext)
Expand All @@ -44,7 +44,7 @@ public async Task<T> CreateAsync(T entity)
await SaveAsync();
return entity;
}

/// <inheritdoc />
public async Task<ICollection<T>> CreateAsync(ICollection<T> entities)
{
Expand Down
2 changes: 1 addition & 1 deletion Submarine.Api/Services/ProviderService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ namespace Submarine.Api.Services;

public class ProviderService
{
private readonly IProviderRepository _repository;
private readonly ILogger<ProviderService> _logger;
private readonly IProviderRepository _repository;

public ProviderService(ILogger<ProviderService> logger, IProviderRepository repository)
{
Expand Down
70 changes: 35 additions & 35 deletions Submarine.Api/Submarine.Api.csproj
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<AssemblyVersion>0.0.1</AssemblyVersion>
<LangVersion>11</LangVersion>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<AssemblyVersion>0.0.1</AssemblyVersion>
<LangVersion>11</LangVersion>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DocumentationFile>bin\Debug\net6.0\Submarine.Api.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DocumentationFile>bin\Debug\net6.0\Submarine.Api.xml</DocumentationFile>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DocumentationFile>bin\Release\net6.0\Submarine.Api.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DocumentationFile>bin\Release\net6.0\Submarine.Api.xml</DocumentationFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AspNetCore.ExceptionHandler" Version="1.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.10">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="7.0.10" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.4" />
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="7.0.1" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AspNetCore.ExceptionHandler" Version="1.1.0"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.10">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="7.0.10"/>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.4"/>
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0"/>
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0"/>
<PackageReference Include="Serilog.Settings.Configuration" Version="7.0.1"/>
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0"/>
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0"/>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Submarine.Core\Submarine.Core.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Submarine.Core\Submarine.Core.csproj"/>
</ItemGroup>

<ItemGroup>
<Folder Include="Models\Response" />
</ItemGroup>
<ItemGroup>
<Folder Include="Models\Response"/>
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion Submarine.Core.Test/Parser/QualityParserServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public QualityParserServiceTest(ITestOutputHelper output)
[InlineData("The Series 2014 S08 1080p Blu-ray AVC DTS-HD MA 5.1-BTN")]
public void Parse_ShouldReturnQualitySourceBlurayDisc_WhenReleaseIsBlurayDisc(string input)
=> AssertQualitySource(input, QualitySource.BLURAY_DISK);

[Theory]
[InlineData("Movie Name 1978 1080p BluRay REMUX AVC FLAC 1.0-BLURANiUM")]
[InlineData("Series!!! on ICE - S01E12[JP BD Remux][ENG subs]")]
Expand Down
28 changes: 17 additions & 11 deletions Submarine.Core.Test/Parser/Release/ReleaseParserServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ public void Parse_ShouldParseAliases_WhenTitleContainsAKA(string input, string t
Assert.Equal(title, parsed.Title);
Assert.Equal(aliases, parsed.Aliases);
}

[Theory]
[InlineData("Anime S01 2021 1080p WEB-DL AVC AAC 2.0 Dual Audio -ZR-", "Anime")]
[InlineData("The Anime Title (Japanese Alias) S01 2021 1080p WEB-DL AVC AAC 2.0 Dual Audio -ZR-", "The Anime Title")]
[InlineData("The Anime Title (Japanese Alias) S04E18 2022 1080p WEB-DL AVC AAC 2.0 Dual Audio -ZR-", "The Anime Title")]
[InlineData("The Anime Title (Japanese Alias) S01 2021 1080p WEB-DL AVC AAC 2.0 Dual Audio -ZR-",
"The Anime Title")]
[InlineData("The Anime Title (Japanese Alias) S04E18 2022 1080p WEB-DL AVC AAC 2.0 Dual Audio -ZR-",
"The Anime Title")]
public void Parse_ShouldParseTitle_WhenReleaseIsAnime(string input, string title)
{
var parsed = _instance.Parse(input);
Expand All @@ -57,10 +59,10 @@ public void Parse_ShouldParseTitle_WhenReleaseIsAnime(string input, string title
public void Parse_ShouldIdentifySeries_WhenReleaseIsSeries(string input)
{
var parsed = _instance.Parse(input);

Assert.Equal(ReleaseType.SERIES, parsed.Type);
}

[Theory]
[InlineData("Movie Name AKA Other Movie Name 1983 1080p BluRay REMUX AVC FLAC 2.0-BLURANiUM")]
[InlineData("Movie.Title.1987.1080p.BluRay.REMUX.DD+2.0.AVC")]
Expand All @@ -69,7 +71,7 @@ public void Parse_ShouldIdentifySeries_WhenReleaseIsSeries(string input)
public void Parse_ShouldIdentifyMovie_WhenReleaseIsMovie(string input)
{
var parsed = _instance.Parse(input);

Assert.Equal(ReleaseType.MOVIE, parsed.Type);
}

Expand All @@ -79,27 +81,31 @@ public void Parse_ShouldParseAbsoluteEpisode_WhenReleaseIsAnime(string input, in
{
var parsed = _instance.Parse(input);

Assert.Contains(absoluteEpisode, parsed.SeriesReleaseData?.AbsoluteEpisodes ?? throw new InvalidOperationException());
Assert.Contains(absoluteEpisode,
parsed.SeriesReleaseData?.AbsoluteEpisodes ?? throw new InvalidOperationException());
}

[Theory]
[InlineData("[HorribleSubs] Anime - 12 [1080p].mkv", QualitySource.WEB_DL)]
[InlineData("[SubsPlease] Anime - 14 (1080p) [3168B4D7].mkv", QualitySource.WEB_DL)]
[InlineData("[Erai-raws] Anime 2nd Season - 11 [1080p][Multiple Subtitle] [ENG][POR-BR][SPA-LA][SPA][GER][ITA][RUS]", QualitySource.WEB_DL)]
[InlineData(
"[Erai-raws] Anime 2nd Season - 11 [1080p][Multiple Subtitle] [ENG][POR-BR][SPA-LA][SPA][GER][ITA][RUS]",
QualitySource.WEB_DL)]
public void Parse_ShouldApplyEdgeCaseReleaseGroupQualitySourceMapping_WhenReleaseHasUnknownSourceAndGroupMatches(
string input, QualitySource expected)
{
var parsed = _instance.Parse(input);

Assert.Equal(expected, parsed.Quality.Resolution.Source);
}

[Theory]
[InlineData("[Erai-raws] Anime - 01 ~ 24 [BD 720p][Multiple Subtitle]", QualitySource.BLURAY)]
public void Parse_ShouldNotApplyEdgeCaseReleaseGroupQualitySourceMapping_IfReleaseSpecifiesQualitySource(string input, QualitySource expected)
public void Parse_ShouldNotApplyEdgeCaseReleaseGroupQualitySourceMapping_IfReleaseSpecifiesQualitySource(
string input, QualitySource expected)
{
var parsed = _instance.Parse(input);

Assert.Equal(expected, parsed.Quality.Resolution.Source);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void Parse_ShouldReturnStreamingProviderDCUniverse_WhenReleaseIsDCUnivers
[InlineData("Show.Title.S04E04.Teambuilding.Exercise.720p.HBO.WEB-DL.DD5.1.H.264-monkee")]
public void Parse_ShouldReturnStreamingProviderHBONow_WhenReleaseIsHBONow(string input)
=> AssertStreamingProvider(input, StreamingProvider.HBO_NOW);

[Theory]
[InlineData("Series.Title.S03E01.2160p.PMTP.WEB-DL.DDP5.1.HDR.HEVC-NTb")]
[InlineData("Movie.2022.Hybrid.2160p.PMTP.WEB-DL.DDPA5.1.DV.HEVC-ShiNobi")]
Expand Down
Loading

0 comments on commit aaeab64

Please sign in to comment.