#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Common.DataAccess.Entities.Plugins;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.Plugins;
///
/// Fixture class for the class.
///
[ExcludeFromCodeCoverage]
public class LibraryMetadataProviderConfigurationEntityFixture
{
///
/// Creates a random valid for the provided media library, plugin and rank.
///
/// The Id of the media library the configuration belongs to.
/// The Id of the plugin providing the metadata.
/// The rank of the metadata provider, determining the order in which providers are tried.
/// Whether the metadata provider is enabled or not.
/// The created .
public LibraryMetadataProviderConfigurationEntity Create(
Guid libraryId,
Guid pluginId,
int rank,
bool isEnabled = true)
{
return new Faker()
.RuleFor(configuration => configuration.Id, faker => faker.Random.Guid())
.RuleFor(configuration => configuration.LibraryId, libraryId)
.RuleFor(configuration => configuration.PluginId, pluginId)
.RuleFor(configuration => configuration.IsEnabled, isEnabled)
.RuleFor(configuration => configuration.Rank, rank)
.RuleFor(configuration => configuration.CreatedOnUtc, faker => faker.Date.Past())
.RuleFor(configuration => configuration.CreatedBy, faker => faker.Random.Guid())
.RuleFor(configuration => configuration.UpdatedOnUtc, faker => faker.Date.Recent())
.RuleFor(configuration => configuration.UpdatedBy, faker => faker.Random.Guid())
.Generate();
}
///
/// Creates a list of instances with randomized test data.
///
/// Number of instances to create.
/// The Id of the media library the configurations belong to.
/// The Id of the plugin providing the metadata.
/// The rank of the metadata providers.
/// List of configured instances.
public List CreateMany(int count, Guid libraryId, Guid pluginId, int rank)
{
return [.. Enumerable.Range(0, count).Select(_ => Create(libraryId, pluginId, rank))];
}
}