mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-02 16:11:10 +00:00
Returns paginated results instead of enumerables
This commit is contained in:
1 parent
871644b3c9
commit
a7fcb420d2
13 files changed
+78
-52
No files matched your search
@@ -4,6 +4,8 @@ using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Plugins;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Plugins;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Common.Mapping.Plugins;
|
||||
using Lumina.Contracts.Responses.Plugins;
|
||||
using System.Collections.Generic;
|
||||
@@ -40,7 +42,7 @@ public class GetPluginsQueryHandler : IQueryHandler<GetPluginsQuery, Result<IRea
|
||||
/// </returns>
|
||||
public async Task<Result<IReadOnlyList<PluginResponse>>> HandleAsync(GetPluginsQuery query, CancellationToken cancellationToken)
|
||||
{
|
||||
Result<IEnumerable<PluginEntity>> getPluginsResult = await _unitOfWork.PluginRepository.GetAllAsync(cancellationToken).ConfigureAwait(false);
|
||||
return getPluginsResult.Match(plugins => Result.From<IReadOnlyList<PluginResponse>>([.. plugins.Select(plugin => plugin.ToResponse())]), errors => errors);
|
||||
Result<PaginatedResultDto<PluginEntity>> getPluginsResult = await _unitOfWork.PluginRepository.GetAllAsync<BaseFilterDto>(cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return getPluginsResult.Match(plugins => Result.From<IReadOnlyList<PluginResponse>>([.. plugins.Data.Select(plugin => plugin.ToResponse())]), errors => errors);
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -1,6 +1,8 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Scheduling;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Common.Mapping.Scheduling;
|
||||
using Lumina.Application.Core.Scheduling.Notifications;
|
||||
using Lumina.Contracts.Responses.Scheduling;
|
||||
@@ -42,10 +44,10 @@ public class ScheduledJobAddedDomainEventHandler : IDomainEventHandler<Scheduled
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public async ValueTask HandleAsync(ScheduledJobAddedDomainEvent domainEvent, CancellationToken cancellationToken)
|
||||
{
|
||||
Result<IEnumerable<ScheduledJobEntity>> getScheduledJobsResult = await _unitOfWork.ScheduledJobRepository.GetAllAsync(cancellationToken).ConfigureAwait(false);
|
||||
Result<PaginatedResultDto<ScheduledJobEntity>> getScheduledJobsResult = await _unitOfWork.ScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
if (getScheduledJobsResult.IsFailure)
|
||||
throw new EventualConsistencyException(getScheduledJobsResult.FirstError, getScheduledJobsResult.Errors);
|
||||
IReadOnlyList<ScheduledJobResponse> scheduledJobResponses = [.. getScheduledJobsResult.Value.Select(scheduledJob => scheduledJob.ToResponse())];
|
||||
IReadOnlyList<ScheduledJobResponse> scheduledJobResponses = [.. getScheduledJobsResult.Value.Data.Select(scheduledJob => scheduledJob.ToResponse())];
|
||||
await _scheduledJobNotifier.SendScheduledJobsAsync(scheduledJobResponses, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -1,6 +1,8 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Scheduling;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Common.Infrastructure.Scheduling;
|
||||
using Lumina.Application.Common.Mapping.Scheduling;
|
||||
using Lumina.Application.Core.Scheduling.Notifications;
|
||||
@@ -49,10 +51,10 @@ public class ScheduledJobCycleStartedDomainEventHandler : IDomainEventHandler<Sc
|
||||
// Start the execution cycle in the scheduler service, which runs the task of the scheduled job once immediately and then on its schedule.
|
||||
await _scheduledJobScheduler.StartCycleAsync(domainEvent.ScheduledJobId, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
Result<IEnumerable<ScheduledJobEntity>> getScheduledJobsResult = await _unitOfWork.ScheduledJobRepository.GetAllAsync(cancellationToken).ConfigureAwait(false);
|
||||
Result<PaginatedResultDto<ScheduledJobEntity>> getScheduledJobsResult = await _unitOfWork.ScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
if (getScheduledJobsResult.IsFailure)
|
||||
throw new EventualConsistencyException(getScheduledJobsResult.FirstError, getScheduledJobsResult.Errors);
|
||||
IReadOnlyList<ScheduledJobResponse> scheduledJobResponses = [.. getScheduledJobsResult.Value.Select(scheduledJob => scheduledJob.ToResponse())];
|
||||
IReadOnlyList<ScheduledJobResponse> scheduledJobResponses = [.. getScheduledJobsResult.Value.Data.Select(scheduledJob => scheduledJob.ToResponse())];
|
||||
await _scheduledJobNotifier.SendScheduledJobsAsync(scheduledJobResponses, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -1,6 +1,8 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Scheduling;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Common.Mapping.Scheduling;
|
||||
using Lumina.Application.Core.Scheduling.Notifications;
|
||||
using Lumina.Contracts.Responses.Scheduling;
|
||||
@@ -42,10 +44,10 @@ public class ScheduledJobCycleStoppedDomainEventHandler : IDomainEventHandler<Sc
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public async ValueTask HandleAsync(ScheduledJobCycleStoppedDomainEvent domainEvent, CancellationToken cancellationToken)
|
||||
{
|
||||
Result<IEnumerable<ScheduledJobEntity>> getScheduledJobsResult = await _unitOfWork.ScheduledJobRepository.GetAllAsync(cancellationToken).ConfigureAwait(false);
|
||||
Result<PaginatedResultDto<ScheduledJobEntity>> getScheduledJobsResult = await _unitOfWork.ScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
if (getScheduledJobsResult.IsFailure)
|
||||
throw new EventualConsistencyException(getScheduledJobsResult.FirstError, getScheduledJobsResult.Errors);
|
||||
IReadOnlyList<ScheduledJobResponse> scheduledJobResponses = [.. getScheduledJobsResult.Value.Select(scheduledJob => scheduledJob.ToResponse())];
|
||||
IReadOnlyList<ScheduledJobResponse> scheduledJobResponses = [.. getScheduledJobsResult.Value.Data.Select(scheduledJob => scheduledJob.ToResponse())];
|
||||
await _scheduledJobNotifier.SendScheduledJobsAsync(scheduledJobResponses, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -1,6 +1,8 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Scheduling;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Common.Mapping.Scheduling;
|
||||
using Lumina.Application.Core.Scheduling.Notifications;
|
||||
using Lumina.Contracts.Responses.Scheduling;
|
||||
@@ -42,10 +44,10 @@ public class ScheduledJobRemovedDomainEventHandler : IDomainEventHandler<Schedul
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public async ValueTask HandleAsync(ScheduledJobRemovedDomainEvent domainEvent, CancellationToken cancellationToken)
|
||||
{
|
||||
Result<IEnumerable<ScheduledJobEntity>> getScheduledJobsResult = await _unitOfWork.ScheduledJobRepository.GetAllAsync(cancellationToken).ConfigureAwait(false);
|
||||
Result<PaginatedResultDto<ScheduledJobEntity>> getScheduledJobsResult = await _unitOfWork.ScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
if (getScheduledJobsResult.IsFailure)
|
||||
throw new EventualConsistencyException(getScheduledJobsResult.FirstError, getScheduledJobsResult.Errors);
|
||||
IReadOnlyList<ScheduledJobResponse> scheduledJobResponses = [.. getScheduledJobsResult.Value.Select(scheduledJob => scheduledJob.ToResponse())];
|
||||
IReadOnlyList<ScheduledJobResponse> scheduledJobResponses = [.. getScheduledJobsResult.Value.Data.Select(scheduledJob => scheduledJob.ToResponse())];
|
||||
await _scheduledJobNotifier.SendScheduledJobsAsync(scheduledJobResponses, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -2,6 +2,8 @@
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Scheduling;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Common.Infrastructure.Authentication;
|
||||
using Lumina.Application.Common.Infrastructure.Authorization;
|
||||
using Lumina.Application.Common.Mapping.Scheduling;
|
||||
@@ -63,10 +65,10 @@ public class GetScheduledJobsQueryHandler : IQueryHandler<GetScheduledJobsQuery,
|
||||
return ApplicationErrors.Authorization.NotAuthorized;
|
||||
|
||||
// Get the scheduled jobs from the storage medium.
|
||||
Result<IEnumerable<ScheduledJobEntity>> getScheduledJobsResult = await _unitOfWork.ScheduledJobRepository.GetAllAsync(cancellationToken).ConfigureAwait(false);
|
||||
Result<PaginatedResultDto<ScheduledJobEntity>> getScheduledJobsResult = await _unitOfWork.ScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
if (getScheduledJobsResult.IsFailure)
|
||||
return getScheduledJobsResult.Errors;
|
||||
|
||||
return Result.From(getScheduledJobsResult.Value.Select(scheduledJob => scheduledJob.ToResponse()));
|
||||
return Result.From(getScheduledJobsResult.Value.Data.Select(scheduledJob => scheduledJob.ToResponse()));
|
||||
}
|
||||
}
|
||||
+7
-5
@@ -1,6 +1,8 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using EntityFrameworkCore.Testing.NSubstitute;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Common.Errors;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Authorization;
|
||||
using Lumina.DataAccess.Core.Repositories.Authorization;
|
||||
@@ -83,25 +85,25 @@ public class PermissionRepositoryTests
|
||||
await _mockContext.SaveChangesAsync();
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<PermissionEntity>> result = await _sut.GetAllAsync(CancellationToken.None);
|
||||
Result<PaginatedResultDto<PermissionEntity>> result = await _sut.GetAllAsync<BaseFilterDto>(cancellationToken: CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal(3, result.Value.Count());
|
||||
Assert.Equal(permissions, result.Value);
|
||||
Assert.Equal(3, result.Value.Data.Count);
|
||||
Assert.Equal(permissions, result.Value.Data);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetAllAsync_WhenNoPermissionsExist_ShouldReturnEmptyList()
|
||||
{
|
||||
// Act
|
||||
Result<IEnumerable<PermissionEntity>> result = await _sut.GetAllAsync(CancellationToken.None);
|
||||
Result<PaginatedResultDto<PermissionEntity>> result = await _sut.GetAllAsync<BaseFilterDto>(cancellationToken: CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Empty(result.Value);
|
||||
Assert.Empty(result.Value.Data);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
+9
-7
@@ -1,6 +1,8 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using EntityFrameworkCore.Testing.NSubstitute;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Common.Errors;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Authorization;
|
||||
using Lumina.DataAccess.Core.Repositories.Authorization;
|
||||
@@ -111,25 +113,25 @@ public class RoleRepositoryTests
|
||||
await _mockContext.SaveChangesAsync();
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<RoleEntity>> result = await _sut.GetAllAsync(CancellationToken.None);
|
||||
Result<PaginatedResultDto<RoleEntity>> result = await _sut.GetAllAsync<BaseFilterDto>(cancellationToken: CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal(2, result.Value.Count());
|
||||
Assert.Equal(roles, result.Value);
|
||||
Assert.Equal(2, result.Value.Data.Count);
|
||||
Assert.Equal(roles, result.Value.Data);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetAllAsync_WhenNoRolesExist_ShouldReturnEmptyList()
|
||||
{
|
||||
// Act
|
||||
Result<IEnumerable<RoleEntity>> result = await _sut.GetAllAsync(CancellationToken.None);
|
||||
Result<PaginatedResultDto<RoleEntity>> result = await _sut.GetAllAsync<BaseFilterDto>(cancellationToken: CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Empty(result.Value);
|
||||
Assert.Empty(result.Value.Data);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -172,7 +174,7 @@ public class RoleRepositoryTests
|
||||
await _mockContext.SaveChangesAsync();
|
||||
|
||||
// Act
|
||||
Result<RoleEntity?> result = await _sut.GetByIdAsync(role.Id, CancellationToken.None);
|
||||
Result<RoleEntity?> result = await _sut.GetByIdAsync(role.Id, cancellationToken: CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
@@ -190,7 +192,7 @@ public class RoleRepositoryTests
|
||||
Guid nonExistentId = Guid.NewGuid();
|
||||
|
||||
// Act
|
||||
Result<RoleEntity?> result = await _sut.GetByIdAsync(nonExistentId, CancellationToken.None);
|
||||
Result<RoleEntity?> result = await _sut.GetByIdAsync(nonExistentId, cancellationToken: CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
|
||||
+7
-5
@@ -1,6 +1,8 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using EntityFrameworkCore.Testing.NSubstitute;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.DataAccess.Core.Repositories.Libraries;
|
||||
using Lumina.DataAccess.Core.UoW;
|
||||
@@ -81,7 +83,7 @@ public class LibraryRepositoryTests
|
||||
await _mockContext.SaveChangesAsync();
|
||||
|
||||
// Act
|
||||
Result<LibraryEntity?> result = await _sut.GetByIdAsync(library.Id, CancellationToken.None);
|
||||
Result<LibraryEntity?> result = await _sut.GetByIdAsync(library.Id, cancellationToken: CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
@@ -94,7 +96,7 @@ public class LibraryRepositoryTests
|
||||
public async Task GetByIdAsync_WhenLibraryDoesNotExist_ShouldReturnNull()
|
||||
{
|
||||
// Act
|
||||
Result<LibraryEntity?> result = await _sut.GetByIdAsync(Guid.NewGuid(), CancellationToken.None);
|
||||
Result<LibraryEntity?> result = await _sut.GetByIdAsync(Guid.NewGuid(), cancellationToken: CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
@@ -147,12 +149,12 @@ public class LibraryRepositoryTests
|
||||
await _mockContext.SaveChangesAsync();
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<LibraryEntity>> result = await _sut.GetAllAsync(CancellationToken.None);
|
||||
Result<PaginatedResultDto<LibraryEntity>> result = await _sut.GetAllAsync<BaseFilterDto>(cancellationToken: CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(3, result.Value.Count());
|
||||
Assert.Equal(libraries, result.Value);
|
||||
Assert.Equal(3, result.Value.Data.Count);
|
||||
Assert.Equal(libraries, result.Value.Data);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
+9
-7
@@ -1,6 +1,8 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using EntityFrameworkCore.Testing.NSubstitute;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Plugins;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Plugins;
|
||||
using Lumina.DataAccess.Core.Repositories.Plugins;
|
||||
using Lumina.DataAccess.Core.UoW;
|
||||
@@ -46,7 +48,7 @@ public class PluginRepositoryTests
|
||||
await _mockContext.SaveChangesAsync();
|
||||
|
||||
// Act
|
||||
Result<PluginEntity?> result = await _sut.GetByIdAsync(plugin.Id, CancellationToken.None);
|
||||
Result<PluginEntity?> result = await _sut.GetByIdAsync(plugin.Id, cancellationToken: CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
@@ -130,26 +132,26 @@ public class PluginRepositoryTests
|
||||
await _mockContext.SaveChangesAsync();
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<PluginEntity>> result = await _sut.GetAllAsync(CancellationToken.None);
|
||||
Result<PaginatedResultDto<PluginEntity>> result = await _sut.GetAllAsync<BaseFilterDto>(cancellationToken: CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal(2, result.Value.Count());
|
||||
Assert.Contains(result.Value, plugin => plugin.Id == plugins[0].Id);
|
||||
Assert.Contains(result.Value, plugin => plugin.Id == plugins[1].Id);
|
||||
Assert.Equal(2, result.Value.Data.Count);
|
||||
Assert.Contains(result.Value.Data, plugin => plugin.Id == plugins[0].Id);
|
||||
Assert.Contains(result.Value.Data, plugin => plugin.Id == plugins[1].Id);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetAllAsync_WhenNoPluginsExist_ShouldReturnEmptyList()
|
||||
{
|
||||
// Act
|
||||
Result<IEnumerable<PluginEntity>> result = await _sut.GetAllAsync(CancellationToken.None);
|
||||
Result<PaginatedResultDto<PluginEntity>> result = await _sut.GetAllAsync<BaseFilterDto>(cancellationToken: CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Empty(result.Value);
|
||||
Assert.Empty(result.Value.Data);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
+6
-4
@@ -1,6 +1,8 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using EntityFrameworkCore.Testing.NSubstitute;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Scheduling;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Scheduling;
|
||||
using Lumina.DataAccess.Core.Repositories.Scheduling;
|
||||
using Lumina.DataAccess.Core.UoW;
|
||||
@@ -47,7 +49,7 @@ public class ScheduledJobRepositoryTests
|
||||
await _mockContext.SaveChangesAsync();
|
||||
|
||||
// Act
|
||||
Result<ScheduledJobEntity?> result = await _sut.GetByIdAsync(scheduledJob.Id, CancellationToken.None);
|
||||
Result<ScheduledJobEntity?> result = await _sut.GetByIdAsync(scheduledJob.Id, cancellationToken: CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
@@ -60,7 +62,7 @@ public class ScheduledJobRepositoryTests
|
||||
public async Task GetByIdAsync_WhenScheduledJobDoesNotExist_ShouldReturnNull()
|
||||
{
|
||||
// Act
|
||||
Result<ScheduledJobEntity?> result = await _sut.GetByIdAsync(Guid.NewGuid(), CancellationToken.None);
|
||||
Result<ScheduledJobEntity?> result = await _sut.GetByIdAsync(Guid.NewGuid(), cancellationToken: CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
@@ -106,11 +108,11 @@ public class ScheduledJobRepositoryTests
|
||||
await _mockContext.SaveChangesAsync();
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<ScheduledJobEntity>> result = await _sut.GetAllAsync(CancellationToken.None);
|
||||
Result<PaginatedResultDto<ScheduledJobEntity>> result = await _sut.GetAllAsync<BaseFilterDto>(cancellationToken: CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(2, result.Value.Count());
|
||||
Assert.Equal(2, result.Value.Data.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
+7
-5
@@ -1,6 +1,8 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using EntityFrameworkCore.Testing.NSubstitute;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Themes;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Themes;
|
||||
using Lumina.DataAccess.Core.Repositories.Themes;
|
||||
using Lumina.DataAccess.Core.UoW;
|
||||
@@ -82,25 +84,25 @@ public class ThemeRepositoryTests
|
||||
await _mockContext.SaveChangesAsync();
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<ThemeEntity>> result = await _sut.GetAllAsync(CancellationToken.None);
|
||||
Result<PaginatedResultDto<ThemeEntity>> result = await _sut.GetAllAsync<BaseFilterDto>(cancellationToken: CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal(3, result.Value.Count());
|
||||
Assert.Equal(themes, result.Value);
|
||||
Assert.Equal(3, result.Value.Data.Count);
|
||||
Assert.Equal(themes, result.Value.Data);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetAllAsync_WhenNoThemesExist_ShouldReturnEmptyList()
|
||||
{
|
||||
// Act
|
||||
Result<IEnumerable<ThemeEntity>> result = await _sut.GetAllAsync(CancellationToken.None);
|
||||
Result<PaginatedResultDto<ThemeEntity>> result = await _sut.GetAllAsync<BaseFilterDto>(cancellationToken: CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Empty(result.Value);
|
||||
Assert.Empty(result.Value.Data);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
+9
-7
@@ -2,6 +2,8 @@
|
||||
using EntityFrameworkCore.Testing.NSubstitute;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Authorization;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.DataAccess.Core.Repositories.Users;
|
||||
@@ -88,25 +90,25 @@ public class UserRepositoryTests
|
||||
await _mockContext.SaveChangesAsync();
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<UserEntity>> result = await _sut.GetAllAsync(CancellationToken.None);
|
||||
Result<PaginatedResultDto<UserEntity>> result = await _sut.GetAllAsync<BaseFilterDto>(cancellationToken: CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal(3, result.Value.Count());
|
||||
Assert.Equal(users, result.Value);
|
||||
Assert.Equal(3, result.Value.Data.Count);
|
||||
Assert.Equal(users, result.Value.Data);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetAllAsync_WhenNoUsersExist_ShouldReturnEmptyList()
|
||||
{
|
||||
// Act
|
||||
Result<IEnumerable<UserEntity>> result = await _sut.GetAllAsync(CancellationToken.None);
|
||||
Result<PaginatedResultDto<UserEntity>> result = await _sut.GetAllAsync<BaseFilterDto>(cancellationToken: CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Empty(result.Value);
|
||||
Assert.Empty(result.Value.Data);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -189,7 +191,7 @@ public class UserRepositoryTests
|
||||
await _mockContext.SaveChangesAsync();
|
||||
|
||||
// Act
|
||||
Result<UserEntity?> result = await _sut.GetByIdAsync(userModel.Id, CancellationToken.None);
|
||||
Result<UserEntity?> result = await _sut.GetByIdAsync(userModel.Id, cancellationToken: CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
@@ -209,7 +211,7 @@ public class UserRepositoryTests
|
||||
Guid nonExistentId = Guid.NewGuid();
|
||||
|
||||
// Act
|
||||
Result<UserEntity?> result = await _sut.GetByIdAsync(nonExistentId, CancellationToken.None);
|
||||
Result<UserEntity?> result = await _sut.GetByIdAsync(nonExistentId, cancellationToken: CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
|
||||
Reference in new issue
Block a user