mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 18:21:10 +00:00
Adds commands and queries validators unit tests
This commit is contained in:
1 parent
7f335b70f1
commit
f393b93ce7
25 files changed
+1553
-307
No files matched your search
+76
@@ -0,0 +1,76 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Commands.AddLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaLibrary.Management.Commands.AddLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AddLibraryCommand"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AddLibraryCommandFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid command to add a media library.
|
||||
/// </summary>
|
||||
/// <param name="title">Optional. The title of the media library.</param>
|
||||
/// <param name="libraryType">Optional. The type of the media library.</param>
|
||||
/// <param name="contentLocations">Optional. The content locations of the media library.</param>
|
||||
/// <param name="coverImage">Optional. The cover image path of the media library.</param>
|
||||
/// <param name="isEnabled">Whether the media library is enabled or not.</param>
|
||||
/// <param name="isLocked">Whether the media library is locked or not.</param>
|
||||
/// <param name="downloadMetadataFromWeb">Whether the media library should download metadata from the web or not.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Whether the metadata should be saved in the media directories or not.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Whether unchanged directories should be skipped during a scan or not.</param>
|
||||
/// <returns>The created command.</returns>
|
||||
public AddLibraryCommand Create(
|
||||
string? title = null,
|
||||
string? libraryType = null,
|
||||
string[]? contentLocations = null,
|
||||
string? coverImage = null,
|
||||
bool isEnabled = true,
|
||||
bool isLocked = false,
|
||||
bool downloadMetadataFromWeb = true,
|
||||
bool shouldSaveMetadataInMediaDirectories = true,
|
||||
bool shouldSkipUnchangedDirectoriesDuringScan = false)
|
||||
{
|
||||
return new Faker<AddLibraryCommand>()
|
||||
.CustomInstantiator(f => new AddLibraryCommand(
|
||||
default!,
|
||||
default!,
|
||||
default!,
|
||||
default!,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
false
|
||||
))
|
||||
.RuleFor(x => x.Title, f => title ?? f.Lorem.Word())
|
||||
.RuleFor(x => x.LibraryType, f => libraryType ?? f.Random.Enum<LibraryType>().ToString())
|
||||
.RuleFor(x => x.ContentLocations, f => contentLocations ?? [f.System.DirectoryPath(), f.System.DirectoryPath(), f.System.DirectoryPath()])
|
||||
.RuleFor(x => x.CoverImage, f => coverImage ?? f.System.FilePath())
|
||||
.RuleFor(x => x.IsEnabled, isEnabled)
|
||||
.RuleFor(x => x.IsLocked, isLocked)
|
||||
.RuleFor(x => x.DownloadMetadataFromWeb, downloadMetadataFromWeb)
|
||||
.RuleFor(x => x.ShouldSaveMetadataInMediaDirectories, shouldSaveMetadataInMediaDirectories)
|
||||
.RuleFor(x => x.ShouldSkipUnchangedDirectoriesDuringScan, shouldSkipUnchangedDirectoriesDuringScan)
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="AddLibraryCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<AddLibraryCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Commands.CancelLibraryScan;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaLibrary.Management.Commands.CancelLibraryScan;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="CancelLibraryScanCommand"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class CancelLibraryScanCommandFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid command to cancel a media library scan.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">Optional. The Id of the media library whose scan is cancelled.</param>
|
||||
/// <param name="scanId">Optional. The Id of the scan to cancel.</param>
|
||||
/// <returns>The created command.</returns>
|
||||
public CancelLibraryScanCommand Create(Guid? libraryId = null, Guid? scanId = null)
|
||||
{
|
||||
return new Faker<CancelLibraryScanCommand>()
|
||||
.CustomInstantiator(f => new CancelLibraryScanCommand(
|
||||
libraryId ?? Guid.NewGuid(),
|
||||
scanId ?? Guid.NewGuid()))
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="CancelLibraryScanCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<CancelLibraryScanCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Commands.DeleteLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaLibrary.Management.Commands.DeleteLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="DeleteLibraryCommand"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class DeleteLibraryCommandFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid command to delete a media library.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the media library to delete.</param>
|
||||
/// <returns>The created command.</returns>
|
||||
public DeleteLibraryCommand Create(Guid? id = null)
|
||||
{
|
||||
return new Faker<DeleteLibraryCommand>()
|
||||
.CustomInstantiator(f => new DeleteLibraryCommand(
|
||||
id ?? Guid.NewGuid()))
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="DeleteLibraryCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<DeleteLibraryCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Commands.ScanLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaLibrary.Management.Commands.ScanLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ScanLibraryCommand"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ScanLibraryCommandFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid command to scan a media library.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the media library to scan.</param>
|
||||
/// <returns>The created command.</returns>
|
||||
public ScanLibraryCommand Create(Guid? id = null)
|
||||
{
|
||||
return new Faker<ScanLibraryCommand>()
|
||||
.CustomInstantiator(f => new ScanLibraryCommand(
|
||||
id ?? Guid.NewGuid()))
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ScanLibraryCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<ScanLibraryCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Commands.UpdateLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaLibrary.Management.Commands.UpdateLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="UpdateLibraryCommand"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UpdateLibraryCommandFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid command to update a media library.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the media library.</param>
|
||||
/// <param name="ownerId">Optional. The Id of the user owning the media library.</param>
|
||||
/// <param name="title">Optional. The title of the media library.</param>
|
||||
/// <param name="libraryType">Optional. The type of the media library.</param>
|
||||
/// <param name="contentLocations">Optional. The content locations of the media library.</param>
|
||||
/// <param name="coverImage">Optional. The cover image path of the media library.</param>
|
||||
/// <param name="isEnabled">Whether the media library is enabled or not.</param>
|
||||
/// <param name="isLocked">Whether the media library is locked or not.</param>
|
||||
/// <param name="downloadMetadataFromWeb">Whether the media library should download metadata from the web or not.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Whether the metadata should be saved in the media directories or not.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Whether unchanged directories should be skipped during a scan or not.</param>
|
||||
/// <returns>The created command.</returns>
|
||||
public UpdateLibraryCommand Create(
|
||||
Guid? id = null,
|
||||
Guid? ownerId = null,
|
||||
string? title = null,
|
||||
string? libraryType = null,
|
||||
string[]? contentLocations = null,
|
||||
string? coverImage = null,
|
||||
bool isEnabled = true,
|
||||
bool isLocked = false,
|
||||
bool downloadMetadataFromWeb = true,
|
||||
bool shouldSaveMetadataInMediaDirectories = true,
|
||||
bool shouldSkipUnchangedDirectoriesDuringScan = false)
|
||||
{
|
||||
return new Faker<UpdateLibraryCommand>()
|
||||
.CustomInstantiator(f => new UpdateLibraryCommand(
|
||||
default,
|
||||
default,
|
||||
default!,
|
||||
default!,
|
||||
default!,
|
||||
default!,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
false
|
||||
))
|
||||
.RuleFor(x => x.Id, id ?? Guid.NewGuid())
|
||||
.RuleFor(x => x.OwnerId, ownerId ?? Guid.NewGuid())
|
||||
.RuleFor(x => x.Title, f => title ?? f.Lorem.Word())
|
||||
.RuleFor(x => x.LibraryType, f => libraryType ?? f.Random.Enum<LibraryType>().ToString())
|
||||
.RuleFor(x => x.ContentLocations, f => contentLocations ?? [f.System.DirectoryPath(), f.System.DirectoryPath(), f.System.DirectoryPath()])
|
||||
.RuleFor(x => x.CoverImage, f => coverImage ?? f.System.FilePath())
|
||||
.RuleFor(x => x.IsEnabled, isEnabled)
|
||||
.RuleFor(x => x.IsLocked, isLocked)
|
||||
.RuleFor(x => x.DownloadMetadataFromWeb, downloadMetadataFromWeb)
|
||||
.RuleFor(x => x.ShouldSaveMetadataInMediaDirectories, shouldSaveMetadataInMediaDirectories)
|
||||
.RuleFor(x => x.ShouldSkipUnchangedDirectoriesDuringScan, shouldSkipUnchangedDirectoriesDuringScan)
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="UpdateLibraryCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<UpdateLibraryCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Queries.GetLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaLibrary.Management.Queries.GetLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetLibraryQuery"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetLibraryQueryFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid query to get a media library.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the media library to get.</param>
|
||||
/// <returns>The created query.</returns>
|
||||
public GetLibraryQuery Create(Guid? id = null)
|
||||
{
|
||||
return new Faker<GetLibraryQuery>()
|
||||
.CustomInstantiator(f => new GetLibraryQuery(
|
||||
id ?? Guid.NewGuid()))
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetLibraryQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<GetLibraryQuery> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Queries.GetLibraryScanProgress;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaLibrary.Management.Queries.GetLibraryScanProgress;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetLibraryScanProgressQuery"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetLibraryScanProgressQueryFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid query to get the progress of a media library scan.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">Optional. The Id of the media library whose scan progress is requested.</param>
|
||||
/// <param name="scanId">Optional. The Id of the media library scan whose progress is requested.</param>
|
||||
/// <returns>The created query.</returns>
|
||||
public GetLibraryScanProgressQuery Create(Guid? libraryId = null, Guid? scanId = null)
|
||||
{
|
||||
return new Faker<GetLibraryScanProgressQuery>()
|
||||
.CustomInstantiator(f => new GetLibraryScanProgressQuery(
|
||||
libraryId ?? Guid.NewGuid(),
|
||||
scanId ?? Guid.NewGuid()))
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetLibraryScanProgressQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<GetLibraryScanProgressQuery> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.Plugins.Commands.ReorderLibraryMetadataProviders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.Plugins.Commands.ReorderLibraryMetadataProviders;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ReorderLibraryMetadataProvidersCommand"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReorderLibraryMetadataProvidersCommandFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid command to reorder the metadata providers of a media library.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">Optional. The Id of the media library whose metadata providers are reordered.</param>
|
||||
/// <param name="pluginIds">Optional. The plugin Ids in the new order.</param>
|
||||
/// <returns>The created command.</returns>
|
||||
public ReorderLibraryMetadataProvidersCommand Create(Guid? libraryId = null, IReadOnlyList<Guid>? pluginIds = null)
|
||||
{
|
||||
return new Faker<ReorderLibraryMetadataProvidersCommand>()
|
||||
.CustomInstantiator(f => new ReorderLibraryMetadataProvidersCommand(
|
||||
default,
|
||||
default!))
|
||||
.RuleFor(x => x.LibraryId, libraryId ?? Guid.NewGuid())
|
||||
.RuleFor(x => x.PluginIds, f => pluginIds ?? [Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()])
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ReorderLibraryMetadataProvidersCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<ReorderLibraryMetadataProvidersCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.Plugins.Commands.SetLibraryMetadataProviderEnabled;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.Plugins.Commands.SetLibraryMetadataProviderEnabled;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="SetLibraryMetadataProviderEnabledCommand"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class SetLibraryMetadataProviderEnabledCommandFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid command to enable or disable a metadata provider for a media library.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">Optional. The Id of the media library whose metadata provider is enabled or disabled.</param>
|
||||
/// <param name="pluginId">Optional. The Id of the plugin providing the metadata.</param>
|
||||
/// <param name="isEnabled">Whether the metadata provider should be enabled for the media library.</param>
|
||||
/// <returns>The created command.</returns>
|
||||
public SetLibraryMetadataProviderEnabledCommand Create(Guid? libraryId = null, Guid? pluginId = null, bool isEnabled = true)
|
||||
{
|
||||
return new Faker<SetLibraryMetadataProviderEnabledCommand>()
|
||||
.CustomInstantiator(f => new SetLibraryMetadataProviderEnabledCommand(
|
||||
default,
|
||||
default,
|
||||
true))
|
||||
.RuleFor(x => x.LibraryId, libraryId ?? Guid.NewGuid())
|
||||
.RuleFor(x => x.PluginId, pluginId ?? Guid.NewGuid())
|
||||
.RuleFor(x => x.IsEnabled, isEnabled)
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="SetLibraryMetadataProviderEnabledCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<SetLibraryMetadataProviderEnabledCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.Plugins.Commands.UpdatePluginSettings;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.Plugins.Commands.UpdatePluginSettings;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="UpdatePluginSettingsCommand"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UpdatePluginSettingsCommandFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid command to update the settings of a plugin.
|
||||
/// </summary>
|
||||
/// <param name="pluginId">Optional. The Id of the plugin.</param>
|
||||
/// <param name="settings">Optional. The settings of the plugin.</param>
|
||||
/// <returns>The created command.</returns>
|
||||
public UpdatePluginSettingsCommand Create(Guid? pluginId = null, IReadOnlyDictionary<string, string>? settings = null)
|
||||
{
|
||||
return new Faker<UpdatePluginSettingsCommand>()
|
||||
.CustomInstantiator(f => new UpdatePluginSettingsCommand(
|
||||
default,
|
||||
default!))
|
||||
.RuleFor(x => x.PluginId, pluginId ?? Guid.NewGuid())
|
||||
.RuleFor(x => x.Settings, f => settings ?? new Dictionary<string, string> { [f.Lorem.Word()] = f.Lorem.Word() })
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="UpdatePluginSettingsCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<UpdatePluginSettingsCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user