mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-02 02:01:10 +00:00
Adapts the tests and fixtures to the refactored domain and persistence layers
This commit is contained in:
1 parent
e6f0c63feb
commit
ef913f5c9e
99 files changed
+612
-171
No files matched your search
+1
-6
@@ -2,7 +2,6 @@
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
@@ -32,14 +31,10 @@ public class LanguageInfoFixture
|
||||
{
|
||||
string[] languages = ["en", "es", "fr", "de", "it", "ja", "ko", "zh", "pt", "ru"];
|
||||
|
||||
Result<LanguageInfo> languageInfoResult = LanguageInfo.Create(
|
||||
return LanguageInfo.Create(
|
||||
languageCode ?? _faker.PickRandom(languages),
|
||||
languageName ?? _faker.Lorem.Word(),
|
||||
nativeName ?? Optional<string>.Some(_faker.Lorem.Word()));
|
||||
|
||||
if (languageInfoResult.IsFailure)
|
||||
throw new InvalidOperationException("Failed to create LanguageInfo: " + string.Join(", ", languageInfoResult.Errors));
|
||||
return languageInfoResult.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+3
-3
@@ -37,7 +37,7 @@ public class LibraryFixture
|
||||
/// <param name="libraryType">Optional. The library type.</param>
|
||||
/// <param name="contentLocations">Optional. The content locations of the library.</param>
|
||||
/// <param name="coverImage">Optional. The cover image of the library.</param>
|
||||
/// <param name="includeCoverImage">Whether the cover image should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeCoverImage">Whether the cover image should be included, or left unset, meaning the library has no cover.</param>
|
||||
/// <param name="isEnabled">Whether the library is enabled.</param>
|
||||
/// <param name="isLocked">Whether the library is locked.</param>
|
||||
/// <param name="canDownloadMetadataFromWeb">Whether metadata download from the web is enabled.</param>
|
||||
@@ -78,7 +78,7 @@ public class LibraryFixture
|
||||
title ?? _faker.Random.String2(_faker.Random.Number(1, 50)),
|
||||
libraryType ?? _faker.PickRandom<LibraryType>(),
|
||||
contentLocations ?? validPaths.Take(_random.Next(1, validPaths.Count)),
|
||||
resolvedCoverImage,
|
||||
Optional<string>.FromNullable(resolvedCoverImage),
|
||||
isEnabled,
|
||||
isLocked,
|
||||
canDownloadMetadataFromWeb,
|
||||
@@ -92,7 +92,7 @@ public class LibraryFixture
|
||||
title ?? _faker.Random.String2(_faker.Random.Number(1, 50)),
|
||||
libraryType ?? _faker.PickRandom<LibraryType>(),
|
||||
contentLocations ?? validPaths.Take(_random.Next(1, validPaths.Count)),
|
||||
resolvedCoverImage,
|
||||
Optional<string>.FromNullable(resolvedCoverImage),
|
||||
isEnabled,
|
||||
isLocked,
|
||||
canDownloadMetadataFromWeb,
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
@@ -44,6 +45,6 @@ public class LibraryScanFailedDomainEventFixture
|
||||
libraryId ?? _libraryIdFixture.Create(),
|
||||
mediaLibraryScanCompositeId ?? _mediaLibraryScanCompositeIdFixture.Create(),
|
||||
occurredOnUtc ?? DateTime.UtcNow,
|
||||
includeErrorMessage ? (errorMessage ?? _faker.Random.Words()) : null);
|
||||
Optional<string>.FromNullable(includeErrorMessage ? (errorMessage ?? _faker.Random.Words()) : null));
|
||||
}
|
||||
}
|
||||
@@ -272,12 +272,12 @@ public class StubApiHttpClient : IApiHttpClient
|
||||
/// </summary>
|
||||
/// <typeparam name="TResponse">The expected type of the response content.</typeparam>
|
||||
/// <param name="endpoint">The API endpoint where the request is being sent.</param>
|
||||
/// <param name="fileStream">The stream of the file to upload.</param>
|
||||
/// <param name="fileName">The name of the file to upload.</param>
|
||||
/// <param name="fileStream">The stream of the file to upload, or <see langword="null"/> when no file is uploaded.</param>
|
||||
/// <param name="fileName">The name of the file to upload, or <see langword="null"/> when no file is uploaded.</param>
|
||||
/// <param name="fieldName">The name of the form field carrying the file.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>The deserialized response containing the result of the PUT request.</returns>
|
||||
public Task<TResponse> PutMultipartAsync<TResponse>(string endpoint, Stream fileStream, string fileName, string fieldName, CancellationToken cancellationToken = default)
|
||||
public Task<TResponse> PutMultipartAsync<TResponse>(string endpoint, Stream? fileStream, string? fileName, string fieldName, CancellationToken cancellationToken = default)
|
||||
{
|
||||
PutRequests.Add((endpoint, fileName));
|
||||
if (_putResponseFactories.TryGetValue(endpoint, out Func<object, object>? responseFactory))
|
||||
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Application.Common.Infrastructure.Authentication;
|
||||
using Lumina.Application.Common.Infrastructure.Time;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.DataAccess.Common.Interceptors;
|
||||
using Lumina.DataAccess.Core.Repositories.Libraries;
|
||||
using Lumina.DataAccess.Core.UoW;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NSubstitute;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.DataAccess.IntegrationTests.Core.Repositories.Libraries;
|
||||
|
||||
/// <summary>
|
||||
/// Contains integration tests for the <see cref="LibraryRepository"/> class, exercising it against a real SQLite database.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryRepositoryTests
|
||||
{
|
||||
private readonly LibraryEntityFixture _libraryEntityFixture = new();
|
||||
private readonly UserEntityFixture _userEntityFixture = new();
|
||||
|
||||
[Fact]
|
||||
public async Task UpdateAsync_WhenNothingChanged_ShouldNotChangeTheLibraryAudit()
|
||||
{
|
||||
// Arrange
|
||||
using SqliteConnection anchorConnection = new($"Data Source=luminadataccess-libraryrepo-update-noop-{Guid.NewGuid()};Mode=Memory;Cache=Shared");
|
||||
anchorConnection.Open();
|
||||
Guid userId = Guid.NewGuid();
|
||||
DateTime utcNow = new(2025, 1, 1, 12, 0, 0, DateTimeKind.Utc);
|
||||
using LuminaDbContext context = CreateAuditedContext(anchorConnection, userId, utcNow);
|
||||
LibraryRepository sut = new(context);
|
||||
context.Users.Add(_userEntityFixture.Create(id: userId));
|
||||
LibraryEntity library = _libraryEntityFixture.Create(userId: userId, contentLocations: ["/media/one", "/media/two"]);
|
||||
context.Libraries.Add(library);
|
||||
await context.SaveChangesAsync();
|
||||
LibraryEntity incoming = await LoadDetachedLibraryAsync(context, library.Id);
|
||||
|
||||
// Act
|
||||
Result<Updated> result = await sut.UpdateAsync(incoming, CancellationToken.None);
|
||||
await context.SaveChangesAsync();
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
LibraryEntity? storedLibrary = await context.Libraries.AsNoTracking().Include(candidate => candidate.ContentLocations).FirstOrDefaultAsync(candidate => candidate.Id == library.Id);
|
||||
Assert.NotNull(storedLibrary);
|
||||
Assert.Null(storedLibrary!.UpdatedOnUtc);
|
||||
Assert.Equal(2, storedLibrary.ContentLocations.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task UpdateAsync_WhenContentLocationsChange_ShouldApplyOnlyTheDeltasAndKeepTheUnchangedOnes()
|
||||
{
|
||||
// Arrange
|
||||
using SqliteConnection anchorConnection = new($"Data Source=luminadataccess-libraryrepo-update-locations-{Guid.NewGuid()};Mode=Memory;Cache=Shared");
|
||||
anchorConnection.Open();
|
||||
Guid userId = Guid.NewGuid();
|
||||
DateTime utcNow = new(2025, 1, 1, 12, 0, 0, DateTimeKind.Utc);
|
||||
using LuminaDbContext context = CreateAuditedContext(anchorConnection, userId, utcNow);
|
||||
LibraryRepository sut = new(context);
|
||||
context.Users.Add(_userEntityFixture.Create(id: userId));
|
||||
LibraryEntity library = _libraryEntityFixture.Create(userId: userId, contentLocations: ["/media/one", "/media/two", "/media/keep"]);
|
||||
context.Libraries.Add(library);
|
||||
await context.SaveChangesAsync();
|
||||
Guid keptLocationId = context.Entry(library.ContentLocations.Single(location => location.Path == "/media/keep")).Property<Guid>("Id").CurrentValue;
|
||||
Guid retainedLocationId = context.Entry(library.ContentLocations.Single(location => location.Path == "/media/one")).Property<Guid>("Id").CurrentValue;
|
||||
LibraryEntity incoming = await LoadDetachedLibraryAsync(context, library.Id);
|
||||
incoming.ContentLocations.Clear();
|
||||
foreach (string path in new[] { "/media/one", "/media/keep", "/media/three" })
|
||||
incoming.ContentLocations.Add(new LibraryContentLocationEntity { Path = path });
|
||||
|
||||
// Act
|
||||
Result<Updated> result = await sut.UpdateAsync(incoming, CancellationToken.None);
|
||||
await context.SaveChangesAsync();
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
LibraryEntity? storedLibrary = await context.Libraries.AsNoTracking().Include(candidate => candidate.ContentLocations).FirstOrDefaultAsync(candidate => candidate.Id == library.Id);
|
||||
Assert.NotNull(storedLibrary);
|
||||
Assert.Equal(3, storedLibrary!.ContentLocations.Count);
|
||||
Assert.Equal(["/media/keep", "/media/one", "/media/three"], [.. storedLibrary.ContentLocations.Select(location => location.Path).OrderBy(path => path)]);
|
||||
// The two locations that did not change must keep their stored row identity, instead of being deleted and re-inserted.
|
||||
Assert.Equal(retainedLocationId, context.Entry(library.ContentLocations.Single(location => location.Path == "/media/one")).Property<Guid>("Id").CurrentValue);
|
||||
Assert.Equal(keptLocationId, context.Entry(library.ContentLocations.Single(location => location.Path == "/media/keep")).Property<Guid>("Id").CurrentValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a real SQLite backed context with the auditing interceptor attached, so that audit columns behave exactly like in production.
|
||||
/// </summary>
|
||||
/// <param name="anchorConnection">The open in-memory SQLite connection that keeps the database alive for the duration of the test.</param>
|
||||
/// <param name="userId">The Id of the user reported as the current user.</param>
|
||||
/// <param name="utcNow">The current UTC time reported by the time provider.</param>
|
||||
/// <returns>The created context.</returns>
|
||||
private static LuminaDbContext CreateAuditedContext(SqliteConnection anchorConnection, Guid userId, DateTime utcNow)
|
||||
{
|
||||
ICurrentUserService currentUserService = Substitute.For<ICurrentUserService>();
|
||||
currentUserService.UserId.Returns(userId);
|
||||
IDateTimeProvider dateTimeProvider = Substitute.For<IDateTimeProvider>();
|
||||
dateTimeProvider.UtcNow.Returns(utcNow);
|
||||
LuminaDbContext context = new(new DbContextOptionsBuilder<LuminaDbContext>()
|
||||
.UseSqlite(anchorConnection.ConnectionString)
|
||||
.AddInterceptors(new UpdateAuditableEntitiesInterceptor(currentUserService, dateTimeProvider))
|
||||
.Options);
|
||||
context.Database.EnsureCreated();
|
||||
return context;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads a detached copy of a stored library, with its content locations, so that it can be handed to the repository as the desired state of an edit.
|
||||
/// </summary>
|
||||
/// <param name="context">The context that tracks the stored library.</param>
|
||||
/// <param name="libraryId">The Id of the library to load.</param>
|
||||
/// <returns>The detached copy of the library.</returns>
|
||||
private static async Task<LibraryEntity> LoadDetachedLibraryAsync(LuminaDbContext context, Guid libraryId)
|
||||
{
|
||||
return await context.Libraries
|
||||
.AsNoTracking()
|
||||
.Include(library => library.ContentLocations)
|
||||
.FirstAsync(library => library.Id == libraryId);
|
||||
}
|
||||
}
|
||||
+15
-1
@@ -47,7 +47,7 @@ public class LuminaDbContextTests : IDisposable
|
||||
|
||||
// Assert
|
||||
// The count assertion fails when a table is added or removed, reminding to update the assertions below.
|
||||
Assert.Equal(32, tableNames.Length);
|
||||
Assert.Equal(46, tableNames.Length);
|
||||
Assert.Contains("Books", tableNames);
|
||||
Assert.Contains("Users", tableNames);
|
||||
Assert.Contains("UserSettings", tableNames);
|
||||
@@ -80,6 +80,20 @@ public class LuminaDbContextTests : IDisposable
|
||||
Assert.Contains("ScheduledJobs", tableNames);
|
||||
Assert.Contains("ScheduledJobExecutions", tableNames);
|
||||
Assert.Contains("SchedulerDisplayPreferences", tableNames);
|
||||
Assert.Contains("Artists", tableNames);
|
||||
Assert.Contains("Albums", tableNames);
|
||||
Assert.Contains("Tracks", tableNames);
|
||||
Assert.Contains("ArtistContributors", tableNames);
|
||||
Assert.Contains("AlbumContributors", tableNames);
|
||||
Assert.Contains("AlbumGenres", tableNames);
|
||||
Assert.Contains("AlbumRatings", tableNames);
|
||||
Assert.Contains("AlbumTags", tableNames);
|
||||
Assert.Contains("TrackContributors", tableNames);
|
||||
Assert.Contains("TrackGenres", tableNames);
|
||||
Assert.Contains("TrackIsrcs", tableNames);
|
||||
Assert.Contains("TrackMoods", tableNames);
|
||||
Assert.Contains("TrackRatings", tableNames);
|
||||
Assert.Contains("TrackTags", tableNames);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
-1
@@ -25,7 +25,6 @@ public class GetDrivesEndpointTests : IClassFixture<AuthenticatedLuminaApiFactor
|
||||
private readonly AuthenticatedLuminaApiFactory _apiFactory;
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
ReferenceHandler = ReferenceHandler.Preserve,
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
-1
@@ -24,7 +24,6 @@ public class GetTypeEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory>
|
||||
private readonly AuthenticatedLuminaApiFactory _apiFactory;
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
ReferenceHandler = ReferenceHandler.Preserve,
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
-1
@@ -25,7 +25,6 @@ public class CombinePathEndpointTests : IClassFixture<AuthenticatedLuminaApiFact
|
||||
private readonly AuthenticatedLuminaApiFactory _apiFactory;
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
ReferenceHandler = ReferenceHandler.Preserve,
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
-1
@@ -27,7 +27,6 @@ public class GetPathParentEndpointTests : IClassFixture<AuthenticatedLuminaApiFa
|
||||
private readonly AuthenticatedLuminaApiFactory _apiFactory;
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
ReferenceHandler = ReferenceHandler.Preserve,
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
-1
@@ -25,7 +25,6 @@ public class GetPathRootEndpointTests : IClassFixture<AuthenticatedLuminaApiFact
|
||||
private readonly AuthenticatedLuminaApiFactory _apiFactory;
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
ReferenceHandler = ReferenceHandler.Preserve,
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
-1
@@ -23,7 +23,6 @@ public class GetPathSeparatorEndpointTests : IClassFixture<AuthenticatedLuminaAp
|
||||
private readonly AuthenticatedLuminaApiFactory _apiFactory;
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
ReferenceHandler = ReferenceHandler.Preserve,
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
-1
@@ -26,7 +26,6 @@ public class SplitPathEndpointTests : IClassFixture<AuthenticatedLuminaApiFactor
|
||||
private readonly AuthenticatedLuminaApiFactory _apiFactory;
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
ReferenceHandler = ReferenceHandler.Preserve,
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
-1
@@ -25,7 +25,6 @@ public class ValidatePathEndpointTests : IClassFixture<AuthenticatedLuminaApiFac
|
||||
private readonly AuthenticatedLuminaApiFactory _apiFactory;
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
ReferenceHandler = ReferenceHandler.Preserve,
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
-1
@@ -25,7 +25,6 @@ public class GetThumbnailEndpointTests : IClassFixture<AuthenticatedLuminaApiFac
|
||||
private readonly AuthenticatedLuminaApiFactory _apiFactory;
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
ReferenceHandler = ReferenceHandler.Preserve,
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Contracts.Fixtures.Core.DTO.Common;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Common.Mapping.Common.Metadata;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="LanguageInfoDtoMapping"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LanguageInfoDtoMappingTests
|
||||
{
|
||||
private readonly LanguageInfoDtoFixture _languageInfoDtoFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToDomainEntity_WhenMappingCompleteLanguageInfoDto_ShouldMapAllPropertiesCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
LanguageInfoDto dto = _languageInfoDtoFixture.Create(languageCode: "EN", languageName: "English", nativeName: "English");
|
||||
|
||||
// Act
|
||||
Result<LanguageInfo> result = dto.ToDomainEntity();
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal("en", result.Value.LanguageCode);
|
||||
Assert.Equal(dto.LanguageName, result.Value.LanguageName);
|
||||
Assert.True(result.Value.NativeName.HasValue);
|
||||
Assert.Equal(dto.NativeName, result.Value.NativeName.Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToDomainEntity_WhenNativeNameIsMissing_ShouldMapWithoutNativeName()
|
||||
{
|
||||
// Arrange
|
||||
LanguageInfoDto dto = _languageInfoDtoFixture.Create(includeNativeName: false);
|
||||
|
||||
// Act
|
||||
Result<LanguageInfo> result = dto.ToDomainEntity();
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(dto.LanguageCode!.ToLowerInvariant(), result.Value.LanguageCode);
|
||||
Assert.Equal(dto.LanguageName, result.Value.LanguageName);
|
||||
Assert.False(result.Value.NativeName.HasValue);
|
||||
}
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Contracts.Fixtures.Core.DTO.Common;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Common;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Common.Mapping.Common.Metadata;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="ReleaseInfoDtoMapping"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReleaseInfoDtoMappingTests
|
||||
{
|
||||
private readonly ReleaseInfoDtoFixture _releaseInfoDtoFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToDomainEntity_WhenMappingCompleteReleaseInfoDto_ShouldMapAllPropertiesCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
ReleaseInfoDto dto = _releaseInfoDtoFixture.Create(
|
||||
originalReleaseDate: new DateOnly(2000, 1, 1),
|
||||
originalReleaseYear: 2000,
|
||||
reReleaseDate: new DateOnly(2010, 1, 1),
|
||||
reReleaseYear: 2010,
|
||||
releaseCountry: ReleaseCountry.AD,
|
||||
releaseVersion: "Director's Cut");
|
||||
|
||||
// Act
|
||||
Result<ReleaseInfo> result = dto.ToDomainEntity();
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.True(result.Value.OriginalReleaseDate.HasValue);
|
||||
Assert.Equal(dto.OriginalReleaseDate!.Value, result.Value.OriginalReleaseDate.Value);
|
||||
Assert.True(result.Value.OriginalReleaseYear.HasValue);
|
||||
Assert.Equal(dto.OriginalReleaseYear!.Value, result.Value.OriginalReleaseYear.Value);
|
||||
Assert.True(result.Value.ReReleaseDate.HasValue);
|
||||
Assert.Equal(dto.ReReleaseDate!.Value, result.Value.ReReleaseDate.Value);
|
||||
Assert.True(result.Value.ReReleaseYear.HasValue);
|
||||
Assert.Equal(dto.ReReleaseYear!.Value, result.Value.ReReleaseYear.Value);
|
||||
Assert.True(result.Value.ReleaseCountry.HasValue);
|
||||
Assert.Equal(dto.ReleaseCountry!.Value, result.Value.ReleaseCountry.Value);
|
||||
Assert.True(result.Value.ReleaseVersion.HasValue);
|
||||
Assert.Equal(dto.ReleaseVersion, result.Value.ReleaseVersion.Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToDomainEntity_WhenOptionalValuesAreMissing_ShouldMapWithoutOptionalValues()
|
||||
{
|
||||
// Arrange
|
||||
ReleaseInfoDto dto = _releaseInfoDtoFixture.Create();
|
||||
|
||||
// Act
|
||||
Result<ReleaseInfo> result = dto.ToDomainEntity();
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.False(result.Value.OriginalReleaseDate.HasValue);
|
||||
Assert.False(result.Value.OriginalReleaseYear.HasValue);
|
||||
Assert.False(result.Value.ReReleaseDate.HasValue);
|
||||
Assert.False(result.Value.ReReleaseYear.HasValue);
|
||||
Assert.False(result.Value.ReleaseCountry.HasValue);
|
||||
Assert.False(result.Value.ReleaseVersion.HasValue);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToDomainEntity_WhenOriginalReleaseDateAndYearDoNotMatch_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
ReleaseInfoDto dto = _releaseInfoDtoFixture.Create(
|
||||
originalReleaseDate: new DateOnly(2025, 1, 1),
|
||||
originalReleaseYear: 2024);
|
||||
|
||||
// Act
|
||||
Result<ReleaseInfo> result = dto.ToDomainEntity();
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToDomainEntity_WhenReReleaseDateAndYearDoNotMatch_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
ReleaseInfoDto dto = _releaseInfoDtoFixture.Create(
|
||||
reReleaseDate: new DateOnly(2025, 1, 1),
|
||||
reReleaseYear: 2024);
|
||||
|
||||
// Act
|
||||
Result<ReleaseInfo> result = dto.ToDomainEntity();
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -48,9 +48,9 @@ public class LibraryMappingTests
|
||||
Assert.Equal(library.Title, result.Title);
|
||||
Assert.Equal(library.LibraryType, result.LibraryType);
|
||||
Assert.Equal(library.ContentLocations.Select(l => l.Path), result.ContentLocations.Select(l => l.Path));
|
||||
Assert.Equal(library.CoverImage, result.CoverImage);
|
||||
Assert.Equal(library.CoverImage.HasValue ? library.CoverImage.Value : null, result.CoverImage);
|
||||
Assert.Equal(library.CreatedOnUtc, result.CreatedOnUtc);
|
||||
Assert.Equal(library.UpdatedOnUtc, result.UpdatedOnUtc);
|
||||
Assert.Equal(library.UpdatedOnUtc.HasValue ? library.UpdatedOnUtc.Value : null, result.UpdatedOnUtc);
|
||||
Assert.True(result.IsEnabled);
|
||||
Assert.False(result.IsLocked);
|
||||
Assert.True(result.CanDownloadMetadataFromWeb);
|
||||
@@ -74,7 +74,7 @@ public class LibraryMappingTests
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Empty(result.ContentLocations);
|
||||
Assert.Equal(library.CoverImage, result.CoverImage);
|
||||
Assert.Equal(library.CoverImage.HasValue ? library.CoverImage.Value : null, result.CoverImage);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -101,7 +101,7 @@ public class LibraryMappingTests
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(libraryType, result.LibraryType);
|
||||
Assert.Equal(library.CoverImage, result.CoverImage);
|
||||
Assert.Equal(library.CoverImage.HasValue ? library.CoverImage.Value : null, result.CoverImage);
|
||||
Assert.True(result.IsEnabled);
|
||||
Assert.False(result.IsLocked);
|
||||
Assert.True(result.CanDownloadMetadataFromWeb);
|
||||
@@ -132,7 +132,7 @@ public class LibraryMappingTests
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(library.ContentLocations.Select(l => l.Path), result.ContentLocations.Select(l => l.Path));
|
||||
Assert.Equal(library.CoverImage, result.CoverImage);
|
||||
Assert.Equal(library.CoverImage.HasValue ? library.CoverImage.Value : null, result.CoverImage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.DataAccess.Common.Persistence;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.DataAccess.UnitTests.Common.Persistence;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="CollectionReconciler"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class CollectionReconcilerTests
|
||||
{
|
||||
private readonly TagEntityFixture _tagEntityFixture = new();
|
||||
private readonly IsbnEntityFixture _isbnEntityFixture = new();
|
||||
private readonly BookContributorEntityFixture _bookContributorEntityFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void Reconcile_WhenAnItemIsNew_ShouldAddItToTheTrackedCollection()
|
||||
{
|
||||
// Arrange
|
||||
List<TagEntity> trackedTags = [];
|
||||
List<TagEntity> incomingTags = [_tagEntityFixture.Create(name: "jazz")];
|
||||
|
||||
// Act
|
||||
CollectionReconciler.Reconcile(
|
||||
trackedTags,
|
||||
incomingTags,
|
||||
trackedTag => trackedTag.Name!,
|
||||
incomingTag => incomingTag.Name!,
|
||||
shouldReplace: (trackedTag, incomingTag) => false,
|
||||
createNew: incomingTag => incomingTag);
|
||||
|
||||
// Assert
|
||||
TagEntity addedTag = Assert.Single(trackedTags);
|
||||
Assert.Same(incomingTags[0], addedTag);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Reconcile_WhenATrackedItemIsAbsentFromTheIncomingSet_ShouldRemoveIt()
|
||||
{
|
||||
// Arrange
|
||||
TagEntity removedTag = _tagEntityFixture.Create(name: "rock");
|
||||
TagEntity keptTag = _tagEntityFixture.Create(name: "jazz");
|
||||
List<TagEntity> trackedTags = [removedTag, keptTag];
|
||||
List<TagEntity> incomingTags = [_tagEntityFixture.Create(name: "jazz")];
|
||||
|
||||
// Act
|
||||
CollectionReconciler.Reconcile(
|
||||
trackedTags,
|
||||
incomingTags,
|
||||
trackedTag => trackedTag.Name!,
|
||||
incomingTag => incomingTag.Name!,
|
||||
shouldReplace: (trackedTag, incomingTag) => false,
|
||||
createNew: incomingTag => incomingTag);
|
||||
|
||||
// Assert
|
||||
TagEntity keptTrackedTag = Assert.Single(trackedTags);
|
||||
Assert.Same(keptTag, keptTrackedTag);
|
||||
Assert.DoesNotContain(removedTag, trackedTags);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Reconcile_WhenAMatchedItemDidNotChange_ShouldKeepTheSameTrackedInstance()
|
||||
{
|
||||
// Arrange
|
||||
TagEntity trackedTag = _tagEntityFixture.Create(name: "rock");
|
||||
List<TagEntity> trackedTags = [trackedTag];
|
||||
List<TagEntity> incomingTags = [_tagEntityFixture.Create(name: "rock")];
|
||||
|
||||
// Act
|
||||
CollectionReconciler.Reconcile(
|
||||
trackedTags,
|
||||
incomingTags,
|
||||
existingTag => existingTag.Name!,
|
||||
incomingTag => incomingTag.Name!,
|
||||
shouldReplace: (existingTag, incomingTag) => false,
|
||||
createNew: incomingTag => incomingTag);
|
||||
|
||||
// Assert
|
||||
TagEntity keptTrackedTag = Assert.Single(trackedTags);
|
||||
Assert.Same(trackedTag, keptTrackedTag);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Reconcile_WhenAMatchedItemChanged_ShouldReplaceOnlyThatItem()
|
||||
{
|
||||
// Arrange
|
||||
IsbnEntity trackedIsbn = _isbnEntityFixture.Create(value: "978-3-16-148410-0", format: IsbnFormat.Isbn10);
|
||||
IsbnEntity unchangedIsbn = _isbnEntityFixture.Create(value: "978-0-306-40615-7", format: IsbnFormat.Isbn13);
|
||||
List<IsbnEntity> trackedIsbns = [trackedIsbn, unchangedIsbn];
|
||||
IsbnEntity incomingChangedIsbn = _isbnEntityFixture.Create(value: "978-3-16-148410-0", format: IsbnFormat.Isbn13);
|
||||
IsbnEntity incomingUnchangedIsbn = _isbnEntityFixture.Create(value: "978-0-306-40615-7", format: IsbnFormat.Isbn13);
|
||||
List<IsbnEntity> incomingIsbns = [incomingChangedIsbn, incomingUnchangedIsbn];
|
||||
|
||||
// Act
|
||||
CollectionReconciler.Reconcile(
|
||||
trackedIsbns,
|
||||
incomingIsbns,
|
||||
existingIsbn => existingIsbn.Value!,
|
||||
incomingIsbn => incomingIsbn.Value!,
|
||||
shouldReplace: (existingIsbn, incomingIsbn) => !existingIsbn.Equals(incomingIsbn),
|
||||
createNew: incomingIsbn => incomingIsbn);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(2, trackedIsbns.Count);
|
||||
Assert.DoesNotContain(trackedIsbn, trackedIsbns);
|
||||
Assert.Contains(incomingChangedIsbn, trackedIsbns);
|
||||
IsbnEntity keptIsbn = trackedIsbns.Single(isbn => isbn.Value == unchangedIsbn.Value);
|
||||
Assert.Same(unchangedIsbn, keptIsbn);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Reconcile_WhenSeveralChangesAreRequested_ShouldApplyAddRemoveAndKeepInASinglePass()
|
||||
{
|
||||
// Arrange
|
||||
BookContributorEntity removedContributor = _bookContributorEntityFixture.Create(role: MediaContributorRole.Author);
|
||||
BookContributorEntity keptContributor = _bookContributorEntityFixture.Create(role: MediaContributorRole.Illustrator);
|
||||
List<BookContributorEntity> trackedContributors = [removedContributor, keptContributor];
|
||||
BookContributorEntity incomingKeptContributor = _bookContributorEntityFixture.Create(
|
||||
bookId: keptContributor.BookId,
|
||||
mediaContributorId: keptContributor.MediaContributorId,
|
||||
role: keptContributor.Role);
|
||||
BookContributorEntity incomingNewContributor = _bookContributorEntityFixture.Create(role: MediaContributorRole.Translator);
|
||||
List<BookContributorEntity> incomingContributors = [incomingKeptContributor, incomingNewContributor];
|
||||
|
||||
// Act
|
||||
CollectionReconciler.Reconcile(
|
||||
trackedContributors,
|
||||
incomingContributors,
|
||||
existingContributor => (existingContributor.MediaContributorId, existingContributor.Role),
|
||||
incomingContributor => (incomingContributor.MediaContributorId, incomingContributor.Role),
|
||||
shouldReplace: (existingContributor, incomingContributor) => false,
|
||||
createNew: incomingContributor => incomingContributor);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(2, trackedContributors.Count);
|
||||
Assert.DoesNotContain(removedContributor, trackedContributors);
|
||||
Assert.Same(keptContributor, trackedContributors.Single(contributor => contributor.MediaContributorId == keptContributor.MediaContributorId));
|
||||
Assert.Same(incomingNewContributor, trackedContributors.Single(contributor => contributor.MediaContributorId == incomingNewContributor.MediaContributorId));
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -83,7 +83,7 @@ public class LibraryScanRepositoryTests
|
||||
await _mockContext.SaveChangesAsync();
|
||||
|
||||
// Act
|
||||
Result<LibraryScanEntity?> result = await _sut.GetByIdAsync(libraryScan.Id, CancellationToken.None);
|
||||
Result<LibraryScanEntity?> result = await _sut.GetByIdAsync(libraryScan.Id, cancellationToken: CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
@@ -95,7 +95,7 @@ public class LibraryScanRepositoryTests
|
||||
public async Task GetByIdAsync_WhenLibraryScanDoesNotExist_ShouldReturnNull()
|
||||
{
|
||||
// Act
|
||||
Result<LibraryScanEntity?> result = await _sut.GetByIdAsync(Guid.NewGuid(), CancellationToken.None);
|
||||
Result<LibraryScanEntity?> result = await _sut.GetByIdAsync(Guid.NewGuid(), cancellationToken: CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
|
||||
+2
-2
@@ -46,7 +46,7 @@ public class ScheduledJobExecutionRepositoryTests
|
||||
await _mockContext.SaveChangesAsync();
|
||||
|
||||
// Act
|
||||
Result<ScheduledJobExecutionEntity?> result = await _sut.GetByIdAsync(execution.Id, CancellationToken.None);
|
||||
Result<ScheduledJobExecutionEntity?> result = await _sut.GetByIdAsync(execution.Id, cancellationToken: CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
@@ -59,7 +59,7 @@ public class ScheduledJobExecutionRepositoryTests
|
||||
public async Task GetByIdAsync_WhenExecutionDoesNotExist_ShouldReturnNull()
|
||||
{
|
||||
// Act
|
||||
Result<ScheduledJobExecutionEntity?> result = await _sut.GetByIdAsync(Guid.NewGuid(), CancellationToken.None);
|
||||
Result<ScheduledJobExecutionEntity?> result = await _sut.GetByIdAsync(Guid.NewGuid(), cancellationToken: CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
|
||||
+2
-2
@@ -81,7 +81,7 @@ public class UserSettingsRepositoryTests
|
||||
await _mockContext.SaveChangesAsync();
|
||||
|
||||
// Act
|
||||
Result<UserSettingsEntity?> result = await _sut.GetByIdAsync(settings.Id, CancellationToken.None);
|
||||
Result<UserSettingsEntity?> result = await _sut.GetByIdAsync(settings.Id, cancellationToken: CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
@@ -94,7 +94,7 @@ public class UserSettingsRepositoryTests
|
||||
public async Task GetByIdAsync_WhenSettingsDoNotExist_ShouldReturnNull()
|
||||
{
|
||||
// Act
|
||||
Result<UserSettingsEntity?> result = await _sut.GetByIdAsync(Guid.NewGuid(), CancellationToken.None);
|
||||
Result<UserSettingsEntity?> result = await _sut.GetByIdAsync(Guid.NewGuid(), cancellationToken: CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
@@ -109,11 +110,11 @@ public class EntityTests
|
||||
|
||||
// Act
|
||||
entity.CreatedOnUtc = createdOnUtc;
|
||||
entity.UpdatedOnUtc = updatedOnUtc;
|
||||
entity.UpdatedOnUtc = Optional<DateTime>.Some(updatedOnUtc);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(createdOnUtc, entity.CreatedOnUtc);
|
||||
Assert.Equal(updatedOnUtc, entity.UpdatedOnUtc);
|
||||
Assert.Equal(Optional<DateTime>.Some(updatedOnUtc), entity.UpdatedOnUtc);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -34,7 +34,7 @@ public class GenreTests
|
||||
public void Create_WhenNameIsNullOrWhitespace_ShouldReturnError(string? name)
|
||||
{
|
||||
// Act
|
||||
Result<Genre> result = Genre.Create(name);
|
||||
Result<Genre> result = Genre.Create(name!);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
|
||||
@@ -34,7 +34,7 @@ public class TagTests
|
||||
public void Create_WhenNameIsNullOrWhitespace_ShouldReturnError(string? name)
|
||||
{
|
||||
// Act
|
||||
Result<Tag> result = Tag.Create(name);
|
||||
Result<Tag> result = Tag.Create(name!);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
|
||||
+10
-8
@@ -59,7 +59,8 @@ public class LibraryTests
|
||||
Assert.Equal(title, result.Value.Title);
|
||||
Assert.Equal(libraryType, result.Value.LibraryType);
|
||||
Assert.Equal(2, result.Value.ContentLocations.Count);
|
||||
Assert.Equal(coverImageSourcePath, result.Value.CoverImage);
|
||||
Assert.True(result.Value.CoverImage.HasValue);
|
||||
Assert.Equal(coverImageSourcePath, result.Value.CoverImage.Value);
|
||||
Assert.False(result.Value.IsEnabled);
|
||||
Assert.True(result.Value.IsLocked);
|
||||
Assert.False(result.Value.CanDownloadMetadataFromWeb);
|
||||
@@ -82,7 +83,7 @@ public class LibraryTests
|
||||
"My Library",
|
||||
LibraryType.Movie,
|
||||
["C:/Media"],
|
||||
null,
|
||||
Optional<string>.None(),
|
||||
isEnabled: true,
|
||||
isLocked: false,
|
||||
canDownloadMetadataFromWeb: true,
|
||||
@@ -108,7 +109,7 @@ public class LibraryTests
|
||||
"My Library",
|
||||
LibraryType.Book,
|
||||
[""],
|
||||
null,
|
||||
Optional<string>.None(),
|
||||
isEnabled: true,
|
||||
isLocked: false,
|
||||
canDownloadMetadataFromWeb: true,
|
||||
@@ -128,10 +129,10 @@ public class LibraryTests
|
||||
Library library = _libraryFixture.Create();
|
||||
|
||||
// Act
|
||||
string? coverImageSourcePath = library.CoverImageSourcePath;
|
||||
Optional<string> coverImageSourcePath = library.CoverImageSourcePath;
|
||||
|
||||
// Assert
|
||||
Assert.Null(coverImageSourcePath);
|
||||
Assert.False(coverImageSourcePath.HasValue);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -143,7 +144,7 @@ public class LibraryTests
|
||||
"My Library",
|
||||
LibraryType.Book,
|
||||
["C:/Media/Books", "D:/Books"],
|
||||
null,
|
||||
Optional<string>.None(),
|
||||
isEnabled: true,
|
||||
isLocked: false,
|
||||
canDownloadMetadataFromWeb: true,
|
||||
@@ -170,7 +171,7 @@ public class LibraryTests
|
||||
"My Library",
|
||||
LibraryType.Book,
|
||||
[contentLocation!],
|
||||
null,
|
||||
Optional<string>.None(),
|
||||
isEnabled: true,
|
||||
isLocked: false,
|
||||
canDownloadMetadataFromWeb: true,
|
||||
@@ -260,6 +261,7 @@ public class LibraryTests
|
||||
library.SetInternalLibraryCoverImagePath(internalPath);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(internalPath, library.CoverImage);
|
||||
Assert.True(library.CoverImage.HasValue);
|
||||
Assert.Equal(internalPath, library.CoverImage.Value);
|
||||
}
|
||||
}
|
||||
+4
-3
@@ -45,18 +45,19 @@ public class LibraryScanFailedDomainEventTests
|
||||
Assert.Equal(libraryId, domainEvent.LibraryId);
|
||||
Assert.Equal(compositeId, domainEvent.MediaLibraryScanCompositeId);
|
||||
Assert.Equal(occurredOnUtc, domainEvent.OccurredOnUtc);
|
||||
Assert.Equal(errorMessage, domainEvent.ErrorMessage);
|
||||
Assert.True(domainEvent.ErrorMessage.HasValue);
|
||||
Assert.Equal(errorMessage, domainEvent.ErrorMessage.Value);
|
||||
Assert.IsType<IDomainEvent>(domainEvent, exactMatch: false);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WhenCalledWithoutErrorMessage_ShouldDefaultErrorMessageToNull()
|
||||
public void Constructor_WhenCalledWithoutErrorMessage_ShouldLeaveErrorMessageUnset()
|
||||
{
|
||||
// Act
|
||||
LibraryScanFailedDomainEvent domainEvent = _libraryScanFailedDomainEventFixture.Create(includeErrorMessage: false);
|
||||
|
||||
// Assert
|
||||
Assert.Null(domainEvent.ErrorMessage);
|
||||
Assert.False(domainEvent.ErrorMessage.HasValue);
|
||||
Assert.IsType<IDomainEvent>(domainEvent, exactMatch: false);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -136,7 +136,7 @@ public class BookTests
|
||||
Assert.Equal(sourceBook.Path, book.Path);
|
||||
Assert.Equal(sourceBook.Metadata, book.Metadata);
|
||||
Assert.Equal(createdOnUtc, book.CreatedOnUtc);
|
||||
Assert.Equal(updatedOnUtc, book.UpdatedOnUtc);
|
||||
Assert.Equal(Optional<DateTime>.Some(updatedOnUtc), book.UpdatedOnUtc);
|
||||
Assert.Equal(sourceBook.ISBNs, book.ISBNs);
|
||||
Assert.Equal(sourceBook.Ratings, book.Ratings);
|
||||
}
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ public class IsbnTests
|
||||
public void Create_WhenValueIsNullOrWhitespace_ShouldReturnError(string? value)
|
||||
{
|
||||
// Act
|
||||
Result<Isbn> result = Isbn.Create(value, IsbnFormat.Isbn10);
|
||||
Result<Isbn> result = Isbn.Create(value!, IsbnFormat.Isbn10);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ public class ScanFailurePublisherTests
|
||||
Arg.Is<LibraryScanFailedDomainEvent>(domainEvent =>
|
||||
domainEvent.LibraryId == libraryId
|
||||
&& domainEvent.MediaLibraryScanCompositeId == compositeId
|
||||
&& domainEvent.ErrorMessage == "The scan job failed"),
|
||||
&& domainEvent.ErrorMessage.HasValue && domainEvent.ErrorMessage.Value == "The scan job failed"),
|
||||
Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
|
||||
+9
-8
@@ -5,12 +5,13 @@ using Lumina.Contracts.Fixtures.Core.DTO.MediaContributors;
|
||||
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Common;
|
||||
using Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Jobs.Common;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors;
|
||||
using Lumina.Infrastructure.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Metadata;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Infrastructure.UnitTests.Core.MediaLibrary.Management.Scanning.Jobs.Common;
|
||||
namespace Lumina.Infrastructure.UnitTests.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Metadata;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="MetadataAggregator"/> class.
|
||||
@@ -31,7 +32,7 @@ public class MetadataAggregatorTests
|
||||
public void Merge_WhenBothMetadataHaveScalarValues_ShouldKeepTheFirstValues()
|
||||
{
|
||||
// Arrange
|
||||
BookMetadataDto first = _bookMetadataDtoFixture.Create(includeOptionalProperties: false,
|
||||
BookMetadataDto first = _bookMetadataDtoFixture.Create(includeOptionalProperties: false,
|
||||
title: "First Title",
|
||||
originalTitle: "First Original Title",
|
||||
description: "First Description",
|
||||
@@ -50,7 +51,7 @@ public class MetadataAggregatorTests
|
||||
barnesAndNobleId: "FIRST-BN",
|
||||
appleBooksId: "FIRST-APPLE",
|
||||
coverImagePath: "First Cover");
|
||||
BookMetadataDto second = _bookMetadataDtoFixture.Create(includeOptionalProperties: false,
|
||||
BookMetadataDto second = _bookMetadataDtoFixture.Create(includeOptionalProperties: false,
|
||||
title: "Second Title",
|
||||
originalTitle: "Second Original Title",
|
||||
description: "Second Description",
|
||||
@@ -235,8 +236,8 @@ public class MetadataAggregatorTests
|
||||
public void Merge_WhenBothHaveContributors_ShouldUnionAndDeDuplicateByDisplayNameAndRole()
|
||||
{
|
||||
// Arrange
|
||||
BookMetadataDto first = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Contributors = [_mediaContributorDtoFixture.Create("Author A", "Author")] };
|
||||
BookMetadataDto second = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Contributors = [_mediaContributorDtoFixture.Create("Author A", "Author"), _mediaContributorDtoFixture.Create("Translator B", "Translator")] };
|
||||
BookMetadataDto first = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Contributors = [_mediaContributorDtoFixture.Create("Author A", MediaContributorRole.Author)] };
|
||||
BookMetadataDto second = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Contributors = [_mediaContributorDtoFixture.Create("Author A", MediaContributorRole.Author), _mediaContributorDtoFixture.Create("Translator B", MediaContributorRole.Translator)] };
|
||||
|
||||
// Act
|
||||
BookMetadataDto result = MetadataAggregator.Merge(first, second);
|
||||
@@ -267,7 +268,7 @@ public class MetadataAggregatorTests
|
||||
public void Merge_WhenOnlyFirstHasCollections_ShouldReturnTheFirstCollections()
|
||||
{
|
||||
// Arrange
|
||||
BookMetadataDto first = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Tags = [_tagDtoFixture.Create(name: "Tag A")], Genres = [_genreDtoFixture.Create(name: "Genre A")], Isbns = [_isbnDtoFixture.Create(value: "9780306406157", format: IsbnFormat.Isbn13)], Contributors = [_mediaContributorDtoFixture.Create("Author A", "Author")], Ratings = [_bookRatingDtoFixture.Create(value: 8m, maxValue: 10m, source: BookRatingSource.Calibre, voteCount: null)] };
|
||||
BookMetadataDto first = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Tags = [_tagDtoFixture.Create(name: "Tag A")], Genres = [_genreDtoFixture.Create(name: "Genre A")], Isbns = [_isbnDtoFixture.Create(value: "9780306406157", format: IsbnFormat.Isbn13)], Contributors = [_mediaContributorDtoFixture.Create("Author A", MediaContributorRole.Author)], Ratings = [_bookRatingDtoFixture.Create(value: 8m, maxValue: 10m, source: BookRatingSource.Calibre, voteCount: null)] };
|
||||
BookMetadataDto second = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Tags = null, Genres = null, Isbns = null, Contributors = null, Ratings = null };
|
||||
|
||||
// Act
|
||||
@@ -286,7 +287,7 @@ public class MetadataAggregatorTests
|
||||
{
|
||||
// Arrange
|
||||
BookMetadataDto first = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Tags = null, Genres = null, Isbns = null, Contributors = null, Ratings = null };
|
||||
BookMetadataDto second = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Tags = [_tagDtoFixture.Create(name: "Tag B")], Genres = [_genreDtoFixture.Create(name: "Genre B")], Isbns = [_isbnDtoFixture.Create(value: "0306406152", format: IsbnFormat.Isbn10)], Contributors = [_mediaContributorDtoFixture.Create("Author B", "Author")], Ratings = [_bookRatingDtoFixture.Create(value: 4.2m, maxValue: 5m, source: BookRatingSource.OpenLibrary, voteCount: 100)] };
|
||||
BookMetadataDto second = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Tags = [_tagDtoFixture.Create(name: "Tag B")], Genres = [_genreDtoFixture.Create(name: "Genre B")], Isbns = [_isbnDtoFixture.Create(value: "0306406152", format: IsbnFormat.Isbn10)], Contributors = [_mediaContributorDtoFixture.Create("Author B", MediaContributorRole.Author)], Ratings = [_bookRatingDtoFixture.Create(value: 4.2m, maxValue: 5m, source: BookRatingSource.OpenLibrary, voteCount: 100)] };
|
||||
|
||||
// Act
|
||||
BookMetadataDto result = MetadataAggregator.Merge(first, second);
|
||||
+1
-1
@@ -60,7 +60,7 @@ public class GetPermissionsEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsFailureError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ public class AddRoleEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsFailureError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
AddRoleRequest request = _addRoleRequestFixture.Create(roleName: "Admin", permissions: [Guid.NewGuid()]);
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ public class DeleteRoleEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsFailureError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
DeleteRoleRequest request = _deleteRoleRequestFixture.Create();
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ public class GetRolePermissionsEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsFailureError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
GetRolePermissionsRequest request = _getRolePermissionsRequestFixture.Create();
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ public class GetRolesEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsFailureError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ public class UpdateRoleEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsFailureError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
UpdateRoleRequest request = _updateRoleRequestFixture.Create(roleName: "UpdatedAdmin");
|
||||
|
||||
+2
-2
@@ -56,7 +56,7 @@ public class GetDrivesEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotFoundError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
@@ -81,7 +81,7 @@ public class GetDrivesEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetDrivesQueryToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetDrivesQueryToSender()
|
||||
{
|
||||
// Arrange
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ public class GetTypeEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetFileSystemQueryToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetFileSystemQueryToSender()
|
||||
{
|
||||
// Arrange
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
|
||||
+3
-3
@@ -57,7 +57,7 @@ public class CombinePathEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotFoundError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
CombinePathRequest request = _combinePathRequestFixture.Create("InvalidPath", "TestUser");
|
||||
@@ -83,7 +83,7 @@ public class CombinePathEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationError_ShouldReturnValidationProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationErrors_ShouldReturnValidationProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
CombinePathRequest request = _combinePathRequestFixture.Create("InvalidPath", "TestUser");
|
||||
@@ -109,7 +109,7 @@ public class CombinePathEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendCombinePathCommandToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendCombinePathCommandToSender()
|
||||
{
|
||||
// Arrange
|
||||
CombinePathRequest request = _combinePathRequestFixture.Create("C:\\Users", "TestUser");
|
||||
|
||||
+3
-3
@@ -60,7 +60,7 @@ public class GetPathParentEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotFoundError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
GetPathParentRequest request = _getPathParentRequestFixture.Create(@"C:\Users\TestUser");
|
||||
@@ -86,7 +86,7 @@ public class GetPathParentEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationError_ShouldReturnValidationProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationErrors_ShouldReturnValidationProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
GetPathParentRequest request = _getPathParentRequestFixture.Create(@"InvalidPath");
|
||||
@@ -112,7 +112,7 @@ public class GetPathParentEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetPathParentQueryToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetPathParentQueryToSender()
|
||||
{
|
||||
// Arrange
|
||||
GetPathParentRequest request = _getPathParentRequestFixture.Create(@"C:\Users\TestUser");
|
||||
|
||||
+3
-3
@@ -58,7 +58,7 @@ public class GetPathRootEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotFoundError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
GetPathRootRequest request = _getPathRootRequestFixture.Create(@"C:\Users\TestUser");
|
||||
@@ -84,7 +84,7 @@ public class GetPathRootEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationError_ShouldReturnValidationProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationErrors_ShouldReturnValidationProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
GetPathRootRequest request = _getPathRootRequestFixture.Create(@"InvalidPath");
|
||||
@@ -110,7 +110,7 @@ public class GetPathRootEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetPathRootQueryToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetPathRootQueryToSender()
|
||||
{
|
||||
// Arrange
|
||||
GetPathRootRequest request = _getPathRootRequestFixture.Create(@"C:\Users\TestUser");
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ public class GetPathSeparatorEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetPathSeparatorQueryToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetPathSeparatorQueryToSender()
|
||||
{
|
||||
// Arrange
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
|
||||
+2
-2
@@ -59,7 +59,7 @@ public class SplitPathEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationErrors_ShouldReturnValidationProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
SplitPathRequest request = _splitPathRequestFixture.Create(@"InvalidPath");
|
||||
@@ -86,7 +86,7 @@ public class SplitPathEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendSplitPathCommandToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendSplitPathCommandToSender()
|
||||
{
|
||||
// Arrange
|
||||
SplitPathRequest request = _splitPathRequestFixture.Create(@"C:\Users\TestUser\Documents");
|
||||
|
||||
+2
-2
@@ -58,7 +58,7 @@ public class ValidatePathEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendValidatePathQueryToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendValidatePathQueryToSender()
|
||||
{
|
||||
// Arrange
|
||||
ValidatePathRequest request = _validatePathRequestFixture.Create(@"C:\Users\TestUser\Documents");
|
||||
@@ -76,7 +76,7 @@ public class ValidatePathEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationError_ShouldReturnValidationProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationErrors_ShouldReturnValidationProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
ValidatePathRequest request = _validatePathRequestFixture.Create(@"C:\Users\TestUser\Documents");
|
||||
|
||||
+2
-2
@@ -60,7 +60,7 @@ public class GetThumbnailEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotFoundError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
GetThumbnailRequest request = _getThumbnailRequestFixture.Create("/path/to/nonexistent/file.jpg", 80);
|
||||
@@ -86,7 +86,7 @@ public class GetThumbnailEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationError_ShouldReturnValidationProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationErrors_ShouldReturnValidationProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
GetThumbnailRequest request = _getThumbnailRequestFixture.Create("/path/to/nonexistent/file.jpg", 80);
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ public class AddLibraryEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsConflictError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
AddLibraryRequest request = _addLibraryRequestFixture.Create();
|
||||
|
||||
+2
-2
@@ -48,7 +48,7 @@ public class CancelLibrariesScanEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsFailureError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
@@ -73,7 +73,7 @@ public class CancelLibrariesScanEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendCancelLibrariesScanCommandToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendCancelLibrariesScanCommandToSender()
|
||||
{
|
||||
// Arrange
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ public class CancelLibraryScanEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotFoundError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
CancelLibraryScanRequest request = _cancelLibraryScanRequestFixture.Create();
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ public class DeleteLibraryEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotFoundError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
DeleteLibraryRequest request = _deleteLibraryRequestFixture.Create();
|
||||
|
||||
+2
-2
@@ -55,7 +55,7 @@ public class GetEnabledLibrariesEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsFailureError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
@@ -80,7 +80,7 @@ public class GetEnabledLibrariesEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetEnabledLibrariesQueryToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetEnabledLibrariesQueryToSender()
|
||||
{
|
||||
// Arrange
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
|
||||
+2
-2
@@ -55,7 +55,7 @@ public class GetLibrariesEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsFailureError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
@@ -80,7 +80,7 @@ public class GetLibrariesEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetLibrariesQueryToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetLibrariesQueryToSender()
|
||||
{
|
||||
// Arrange
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ public class GetLibraryEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotFoundError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
GetLibraryRequest request = _getLibraryRequestFixture.Create();
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ public class GetLibraryScanProgressEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotFoundError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
GetLibraryScanProgressRequest request = _getLibraryScanProgressRequestFixture.Create();
|
||||
|
||||
+2
-2
@@ -60,7 +60,7 @@ public class GetRunningLibraryScansEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsFailureError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
@@ -85,7 +85,7 @@ public class GetRunningLibraryScansEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetRunningLibraryScansQueryToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetRunningLibraryScansQueryToSender()
|
||||
{
|
||||
// Arrange
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
|
||||
+2
-2
@@ -59,7 +59,7 @@ public class ScanLibrariesEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsFailureError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
@@ -84,7 +84,7 @@ public class ScanLibrariesEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendScanLibrariesCommandToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendScanLibrariesCommandToSender()
|
||||
{
|
||||
// Arrange
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ public class ScanLibraryEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotFoundError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
ScanLibraryRequest request = _scanLibraryRequestFixture.Create();
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ public class UpdateLibraryEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotFoundError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
UpdateLibraryRequest request = _updateLibraryRequestFixture.Create();
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ public class CheckInitializationEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendCheckInitializationQueryToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendCheckInitializationQueryToSender()
|
||||
{
|
||||
// Arrange
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ public class SetupApplicationEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsConflictError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
RegistrationRequest request = _registrationRequestFixture.Create();
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ public class GetLibraryArtworkProvidersEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotFoundError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
GetLibraryArtworkProvidersRequest request = _getLibraryArtworkProvidersRequestFixture.Create();
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ public class GetLibraryMetadataProvidersEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotFoundError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
GetLibraryMetadataProvidersRequest request = _getLibraryMetadataProvidersRequestFixture.Create();
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ public class GetPluginSettingsEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotFoundError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
GetPluginSettingsRequest request = _getPluginSettingsRequestFixture.Create();
|
||||
|
||||
+2
-2
@@ -56,7 +56,7 @@ public class GetPluginsEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsFailureError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
@@ -81,7 +81,7 @@ public class GetPluginsEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetPluginsQueryToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetPluginsQueryToSender()
|
||||
{
|
||||
// Arrange
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ public class ReorderLibraryArtworkProvidersEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotFoundError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
ReorderLibraryArtworkProvidersRequest request = _reorderLibraryArtworkProvidersRequestFixture.Create();
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ public class ReorderLibraryMetadataProvidersEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotFoundError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
ReorderLibraryMetadataProvidersRequest request = _reorderLibraryMetadataProvidersRequestFixture.Create();
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ public class SetLibraryArtworkProviderEnabledEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotFoundError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
SetLibraryArtworkProviderEnabledRequest request = _setLibraryArtworkProviderEnabledRequestFixture.Create();
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ public class SetLibraryMetadataProviderEnabledEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotFoundError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
SetLibraryMetadataProviderEnabledRequest request = _setLibraryMetadataProviderEnabledRequestFixture.Create();
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ public class UpdatePluginSettingsEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotFoundError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
UpdatePluginSettingsRequest request = _updatePluginSettingsRequestFixture.Create();
|
||||
|
||||
+2
-2
@@ -66,7 +66,7 @@ public class AddScheduledJobEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsFailureError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
AddScheduledJobRequest request = _addScheduledJobRequestFixture.Create();
|
||||
@@ -86,7 +86,7 @@ public class AddScheduledJobEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendMappedCommandToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendMappedCommandToSender()
|
||||
{
|
||||
// Arrange
|
||||
AddScheduledJobRequest request = _addScheduledJobRequestFixture.Create(
|
||||
|
||||
+3
-3
@@ -66,7 +66,7 @@ public class FireScheduledJobEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotFoundError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
FireScheduledJobRequest request = _fireScheduledJobRequestFixture.Create();
|
||||
@@ -86,7 +86,7 @@ public class FireScheduledJobEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotAuthorized_ShouldReturnForbiddenProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotAuthorizedError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
FireScheduledJobRequest request = _fireScheduledJobRequestFixture.Create();
|
||||
@@ -103,7 +103,7 @@ public class FireScheduledJobEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendMappedCommandToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendMappedCommandToSender()
|
||||
{
|
||||
// Arrange
|
||||
FireScheduledJobRequest request = _fireScheduledJobRequestFixture.Create();
|
||||
|
||||
+2
-2
@@ -61,7 +61,7 @@ public class GetScheduledJobHistoryEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsUnauthorizedError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
GetScheduledJobHistoryRequest request = _getScheduledJobHistoryRequestFixture.Create();
|
||||
@@ -78,7 +78,7 @@ public class GetScheduledJobHistoryEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendMappedQueryToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendMappedQueryToSender()
|
||||
{
|
||||
// Arrange
|
||||
GetScheduledJobHistoryRequest request = _getScheduledJobHistoryRequestFixture.Create();
|
||||
|
||||
+2
-2
@@ -56,7 +56,7 @@ public class GetScheduledJobsEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsUnauthorizedError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
@@ -72,7 +72,7 @@ public class GetScheduledJobsEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendQueryToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendQueryToSender()
|
||||
{
|
||||
// Arrange
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
|
||||
+2
-2
@@ -54,7 +54,7 @@ public class GetSchedulerDisplayPreferencesEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsUnauthorizedError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
@@ -70,7 +70,7 @@ public class GetSchedulerDisplayPreferencesEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendQueryToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendQueryToSender()
|
||||
{
|
||||
// Arrange
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
|
||||
+3
-3
@@ -55,7 +55,7 @@ public class RemoveScheduledJobEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotFoundError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
RemoveScheduledJobRequest request = _removeScheduledJobRequestFixture.Create();
|
||||
@@ -73,7 +73,7 @@ public class RemoveScheduledJobEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotAuthorized_ShouldReturnForbiddenProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotAuthorizedError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
RemoveScheduledJobRequest request = _removeScheduledJobRequestFixture.Create();
|
||||
@@ -90,7 +90,7 @@ public class RemoveScheduledJobEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendMappedCommandToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendMappedCommandToSender()
|
||||
{
|
||||
// Arrange
|
||||
RemoveScheduledJobRequest request = _removeScheduledJobRequestFixture.Create();
|
||||
|
||||
+3
-3
@@ -61,7 +61,7 @@ public class StartScheduledJobEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotFoundError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
StartScheduledJobRequest request = _startScheduledJobRequestFixture.Create();
|
||||
@@ -79,7 +79,7 @@ public class StartScheduledJobEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotAuthorized_ShouldReturnForbiddenProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotAuthorizedError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
StartScheduledJobRequest request = _startScheduledJobRequestFixture.Create();
|
||||
@@ -96,7 +96,7 @@ public class StartScheduledJobEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendMappedCommandToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendMappedCommandToSender()
|
||||
{
|
||||
// Arrange
|
||||
StartScheduledJobRequest request = _startScheduledJobRequestFixture.Create();
|
||||
|
||||
+3
-3
@@ -61,7 +61,7 @@ public class StopScheduledJobEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsFailureError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
StopScheduledJobRequest request = _stopScheduledJobRequestFixture.Create();
|
||||
@@ -79,7 +79,7 @@ public class StopScheduledJobEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotAuthorized_ShouldReturnForbiddenProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotAuthorizedError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
StopScheduledJobRequest request = _stopScheduledJobRequestFixture.Create();
|
||||
@@ -96,7 +96,7 @@ public class StopScheduledJobEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendMappedCommandToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendMappedCommandToSender()
|
||||
{
|
||||
// Arrange
|
||||
StopScheduledJobRequest request = _stopScheduledJobRequestFixture.Create();
|
||||
|
||||
+3
-3
@@ -55,7 +55,7 @@ public class UpdateSchedulerDisplayPreferencesEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsFailureError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
UpdateSchedulerDisplayPreferencesRequest request = _updateSchedulerDisplayPreferencesRequestFixture.Create();
|
||||
@@ -73,7 +73,7 @@ public class UpdateSchedulerDisplayPreferencesEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotAuthorized_ShouldReturnForbiddenProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotAuthorizedError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
UpdateSchedulerDisplayPreferencesRequest request = _updateSchedulerDisplayPreferencesRequestFixture.Create();
|
||||
@@ -90,7 +90,7 @@ public class UpdateSchedulerDisplayPreferencesEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendMappedCommandToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendMappedCommandToSender()
|
||||
{
|
||||
// Arrange
|
||||
UpdateSchedulerDisplayPreferencesRequest request = _updateSchedulerDisplayPreferencesRequestFixture.Create();
|
||||
|
||||
+2
-2
@@ -129,7 +129,7 @@ public class DeleteThemeEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationError_ShouldReturnValidationProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationErrors_ShouldReturnValidationProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
DeleteThemeRequest request = _deleteThemeRequestFixture.Create();
|
||||
@@ -155,7 +155,7 @@ public class DeleteThemeEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendDeleteThemeCommandToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendDeleteThemeCommandToSender()
|
||||
{
|
||||
// Arrange
|
||||
DeleteThemeRequest request = _deleteThemeRequestFixture.Create();
|
||||
|
||||
+2
-2
@@ -129,7 +129,7 @@ public class RestoreThemeEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationError_ShouldReturnValidationProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationErrors_ShouldReturnValidationProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
RestoreThemeRequest request = _restoreThemeRequestFixture.Create();
|
||||
@@ -155,7 +155,7 @@ public class RestoreThemeEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendRestoreThemeCommandToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendRestoreThemeCommandToSender()
|
||||
{
|
||||
// Arrange
|
||||
RestoreThemeRequest request = _restoreThemeRequestFixture.Create();
|
||||
|
||||
+2
-2
@@ -110,7 +110,7 @@ public class SetCurrentThemeEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationError_ShouldReturnValidationProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationErrors_ShouldReturnValidationProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
SetCurrentThemeRequest request = _setCurrentThemeRequestFixture.Create();
|
||||
@@ -136,7 +136,7 @@ public class SetCurrentThemeEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendSetCurrentThemeCommandToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendSetCurrentThemeCommandToSender()
|
||||
{
|
||||
// Arrange
|
||||
SetCurrentThemeRequest request = _setCurrentThemeRequestFixture.Create();
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@ public class GetCurrentThemeEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetCurrentThemeQueryToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetCurrentThemeQueryToSender()
|
||||
{
|
||||
// Arrange
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
|
||||
+2
-2
@@ -87,7 +87,7 @@ public class GetThemeArchiveEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationError_ShouldReturnValidationProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationErrors_ShouldReturnValidationProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
GetThemeArchiveRequest request = _getThemeArchiveRequestFixture.Create();
|
||||
@@ -113,7 +113,7 @@ public class GetThemeArchiveEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetThemeArchiveQueryToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetThemeArchiveQueryToSender()
|
||||
{
|
||||
// Arrange
|
||||
GetThemeArchiveRequest request = _getThemeArchiveRequestFixture.Create();
|
||||
|
||||
+2
-2
@@ -86,7 +86,7 @@ public class GetThemeAssetEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationError_ShouldReturnValidationProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationErrors_ShouldReturnValidationProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
GetThemeAssetRequest request = _getThemeAssetRequestFixture.Create();
|
||||
@@ -112,7 +112,7 @@ public class GetThemeAssetEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetThemeAssetQueryToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetThemeAssetQueryToSender()
|
||||
{
|
||||
// Arrange
|
||||
GetThemeAssetRequest request = _getThemeAssetRequestFixture.Create();
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@ public class GetThemeSettingsEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetThemeSettingsQueryToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetThemeSettingsQueryToSender()
|
||||
{
|
||||
// Arrange
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
|
||||
+2
-2
@@ -84,7 +84,7 @@ public class GetThemeTemplateEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationError_ShouldReturnValidationProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationErrors_ShouldReturnValidationProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
GetThemeTemplateRequest request = _getThemeTemplateRequestFixture.Create();
|
||||
@@ -110,7 +110,7 @@ public class GetThemeTemplateEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetThemeTemplateQueryToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetThemeTemplateQueryToSender()
|
||||
{
|
||||
// Arrange
|
||||
GetThemeTemplateRequest request = _getThemeTemplateRequestFixture.Create();
|
||||
|
||||
+1
-1
@@ -81,7 +81,7 @@ public class GetThemesEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetThemesQueryToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetThemesQueryToSender()
|
||||
{
|
||||
// Arrange
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ public class ChangePasswordEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationErrors_ShouldReturnValidationProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
ChangePasswordRequest request = _changePasswordRequestFixture.Create();
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ public class GetUsersEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsFailureError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ public class LoginEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationErrors_ShouldReturnValidationProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
LoginRequest request = _loginRequestFixture.Create();
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ public class RecoverPasswordEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationErrors_ShouldReturnValidationProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
RecoverPasswordRequest request = _recoverPasswordRequestFixture.Create();
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ public class RegisterEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationErrors_ShouldReturnValidationProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
RegistrationRequest request = _registrationRequestFixture.Create();
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ public class GetAuthorizationEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsUnauthorizedError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
GetAuthorizationRequest request = _getAuthorizationRequestFixture.Create();
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ public class GetUserPermissionsEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsFailureError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
GetUserPermissionsRequest request = _getUserPermissionsRequestFixture.Create();
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ public class GetUserRoleEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsFailureError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
GetUserRoleRequest request = _getUserRoleRequestFixture.Create();
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ public class UpdateUserRoleAndPermissionsEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsFailureError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
UpdateUserRoleAndPermissionsRequest request = _updateUserRoleAndPermissionsRequestFixture.Create();
|
||||
|
||||
+2
-2
@@ -54,7 +54,7 @@ public class GetUserSettingsEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsFailureError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
@@ -76,7 +76,7 @@ public class GetUserSettingsEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetUserSettingsQueryToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetUserSettingsQueryToSender()
|
||||
{
|
||||
// Arrange
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
|
||||
+2
-2
@@ -53,7 +53,7 @@ public class UpdateUserSettingsEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationErrors_ShouldReturnValidationProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
UpdateUserSettingsRequest request = _updateUserSettingsRequestFixture.Create(isPaginationEnabled: true, itemsPerPage: 0, shouldIgnoreThePrefixForAlphaPicker: false, isThemeCachingEnabled: true, shouldAggregateMetadataWhenMissing: false);
|
||||
@@ -75,7 +75,7 @@ public class UpdateUserSettingsEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendUpdateUserSettingsCommandToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendUpdateUserSettingsCommandToSender()
|
||||
{
|
||||
// Arrange
|
||||
UpdateUserSettingsRequest request = _updateUserSettingsRequestFixture.Create(isPaginationEnabled: true, itemsPerPage: 24, shouldIgnoreThePrefixForAlphaPicker: true, isThemeCachingEnabled: true, shouldAggregateMetadataWhenMissing: false);
|
||||
|
||||
+6
-6
@@ -37,7 +37,7 @@ public class ThemeCachePreferenceServiceTests
|
||||
Guid userId = Guid.NewGuid();
|
||||
|
||||
// Act
|
||||
bool result = await _sut.GetAsync(userId, defaultValue: true, CancellationToken.None);
|
||||
bool result = await _sut.GetAsync(userId, isCachingEnabledByDefault: true, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
@@ -50,7 +50,7 @@ public class ThemeCachePreferenceServiceTests
|
||||
Guid userId = Guid.NewGuid();
|
||||
|
||||
// Act
|
||||
bool result = await _sut.GetAsync(userId, defaultValue: false, CancellationToken.None);
|
||||
bool result = await _sut.GetAsync(userId, isCachingEnabledByDefault: false, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result);
|
||||
@@ -64,7 +64,7 @@ public class ThemeCachePreferenceServiceTests
|
||||
|
||||
// Act
|
||||
await _sut.SetAsync(userId, isEnabled: true, CancellationToken.None);
|
||||
bool result = await _sut.GetAsync(userId, defaultValue: false, CancellationToken.None);
|
||||
bool result = await _sut.GetAsync(userId, isCachingEnabledByDefault: false, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
@@ -79,7 +79,7 @@ public class ThemeCachePreferenceServiceTests
|
||||
// Act
|
||||
await _sut.SetAsync(userId, isEnabled: true, CancellationToken.None);
|
||||
await _sut.SetAsync(userId, isEnabled: false, CancellationToken.None);
|
||||
bool result = await _sut.GetAsync(userId, defaultValue: true, CancellationToken.None);
|
||||
bool result = await _sut.GetAsync(userId, isCachingEnabledByDefault: true, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result);
|
||||
@@ -94,8 +94,8 @@ public class ThemeCachePreferenceServiceTests
|
||||
|
||||
// Act
|
||||
await _sut.SetAsync(firstUserId, isEnabled: true, CancellationToken.None);
|
||||
bool firstUserResult = await _sut.GetAsync(firstUserId, defaultValue: false, CancellationToken.None);
|
||||
bool secondUserResult = await _sut.GetAsync(secondUserId, defaultValue: false, CancellationToken.None);
|
||||
bool firstUserResult = await _sut.GetAsync(firstUserId, isCachingEnabledByDefault: false, CancellationToken.None);
|
||||
bool secondUserResult = await _sut.GetAsync(secondUserId, isCachingEnabledByDefault: false, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.True(firstUserResult);
|
||||
|
||||
Reference in new issue
Block a user