mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 13:11:10 +00:00
Renames project paths from Lumina to Nemera
This commit is contained in:
1 parent
ce6fddb4c9
commit
0f659a4877
6450 files changed
No files matched your search
@@ -0,0 +1,497 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||
using Lumina.Presentation.Web.Common.Enums.Authorization;
|
||||
using Lumina.Presentation.Web.Common.Exceptions;
|
||||
using Lumina.Presentation.Web.Common.Responses.Authorization;
|
||||
using Lumina.Presentation.Web.Common.Responses.UsersManagement;
|
||||
using Lumina.Presentation.Web.Common.Routes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Api;
|
||||
|
||||
/// <summary>
|
||||
/// Test double for the <see cref="IApiHttpClient"/> interface, allowing integration and security tests to stub the
|
||||
/// remote API responses without hosting a real backend.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class StubApiHttpClient : IApiHttpClient
|
||||
{
|
||||
private readonly Dictionary<string, Func<object>> _getResponseFactories = [];
|
||||
private readonly Dictionary<string, Func<object, object>> _postResponseFactories = [];
|
||||
private readonly Dictionary<string, Func<object, object>> _putResponseFactories = [];
|
||||
private readonly Dictionary<string, ApiException> _postExceptions = [];
|
||||
private readonly Dictionary<string, ApiException> _putExceptions = [];
|
||||
private readonly HashSet<string> _postBodylessSuccessEndpoints = [];
|
||||
private readonly Dictionary<string, Type> _postPayloadTypes = [];
|
||||
private readonly Dictionary<string, Type> _putPayloadTypes = [];
|
||||
private readonly HashSet<string> _deleteSuccessEndpoints = [];
|
||||
private readonly Dictionary<string, ApiException> _deleteExceptions = [];
|
||||
private BlobDataDto? _blobResponse;
|
||||
private ApiException? _blobException;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the authorization response returned for the <c>auth/get-authorization</c> endpoint. It defaults to an Administrator with every permission.
|
||||
/// </summary>
|
||||
public GetAuthorizationResponse AuthorizationResponse { get; set; } = CreateDefaultAuthorizationResponse();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the exception thrown when the <c>auth/get-authorization</c> endpoint is called, or <see langword="null"/> to return
|
||||
/// <see cref="AuthorizationResponse"/>. It simulates an API outage during authorization.
|
||||
/// </summary>
|
||||
public Exception? AuthorizationException { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the initialization response returned for the <c>initialization</c> endpoint.
|
||||
/// </summary>
|
||||
public InitializationResponse InitializationResponse { get; set; } = new() { IsInitialized = true };
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the login response returned for the <c>auth/login</c> endpoint.
|
||||
/// </summary>
|
||||
public LoginResponse LoginResponse { get; set; } = new(Guid.NewGuid(), "testuser", "test_jwt_token", false);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of GET endpoints that were requested.
|
||||
/// </summary>
|
||||
public List<string> GetEndpointsCalled { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of POST requests that were sent, with their payloads.
|
||||
/// </summary>
|
||||
public List<(string Endpoint, object? Data)> PostRequests { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of PUT requests that were sent, with their payloads.
|
||||
/// </summary>
|
||||
public List<(string Endpoint, object? Data)> PutRequests { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of DELETE endpoints that were requested.
|
||||
/// </summary>
|
||||
public List<string> DeleteEndpointsCalled { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of blob endpoints that were requested.
|
||||
/// </summary>
|
||||
public List<string> BlobEndpointsCalled { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Registers the response returned when the specified GET endpoint is called.
|
||||
/// </summary>
|
||||
/// <typeparam name="TResponse">The type of the response.</typeparam>
|
||||
/// <param name="endpoint">The API endpoint for which to register the response.</param>
|
||||
/// <param name="response">The response to return.</param>
|
||||
public void RegisterGetResponse<TResponse>(string endpoint, TResponse response) where TResponse : class
|
||||
{
|
||||
_getResponseFactories[endpoint] = () => response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers the response factory invoked when the specified GET endpoint is called.
|
||||
/// </summary>
|
||||
/// <param name="endpoint">The API endpoint for which to register the response factory.</param>
|
||||
/// <param name="responseFactory">The factory that produces the response.</param>
|
||||
public void RegisterGetResponseFactory(string endpoint, Func<object> responseFactory)
|
||||
{
|
||||
_getResponseFactories[endpoint] = responseFactory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers the response returned when the specified POST endpoint is called.
|
||||
/// </summary>
|
||||
/// <typeparam name="TResponse">The type of the response.</typeparam>
|
||||
/// <param name="endpoint">The API endpoint for which to register the response.</param>
|
||||
/// <param name="response">The response to return.</param>
|
||||
public void RegisterPostResponse<TResponse>(string endpoint, TResponse response) where TResponse : class
|
||||
{
|
||||
_postResponseFactories[endpoint] = _ => response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers the response factory invoked when the specified POST endpoint is called.
|
||||
/// </summary>
|
||||
/// <param name="endpoint">The API endpoint for which to register the response factory.</param>
|
||||
/// <param name="responseFactory">The factory that produces the response from the request payload.</param>
|
||||
public void RegisterPostResponseFactory(string endpoint, Func<object, object> responseFactory)
|
||||
{
|
||||
_postResponseFactories[endpoint] = responseFactory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers the exception thrown when the specified POST endpoint is called.
|
||||
/// </summary>
|
||||
/// <param name="endpoint">The API endpoint for which to register the exception.</param>
|
||||
/// <param name="exception">The exception to throw.</param>
|
||||
public void RegisterPostException(string endpoint, ApiException exception)
|
||||
{
|
||||
_postExceptions[endpoint] = exception;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers the exception thrown when the specified GET endpoint is called.
|
||||
/// </summary>
|
||||
/// <param name="endpoint">The API endpoint for which to register the exception.</param>
|
||||
/// <param name="exception">The exception to throw.</param>
|
||||
public void RegisterGetException(string endpoint, ApiException exception)
|
||||
{
|
||||
_getResponseFactories[endpoint] = () => throw exception;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers the exception thrown when the specified PUT endpoint is called.
|
||||
/// </summary>
|
||||
/// <param name="endpoint">The API endpoint for which to register the exception.</param>
|
||||
/// <param name="exception">The exception to throw.</param>
|
||||
public void RegisterPutException(string endpoint, ApiException exception)
|
||||
{
|
||||
_putExceptions[endpoint] = exception;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers the response returned when the specified PUT endpoint is called.
|
||||
/// </summary>
|
||||
/// <typeparam name="TResponse">The type of the response.</typeparam>
|
||||
/// <param name="endpoint">The API endpoint for which to register the response.</param>
|
||||
/// <param name="response">The response to return.</param>
|
||||
public void RegisterPutResponse<TResponse>(string endpoint, TResponse response) where TResponse : class
|
||||
{
|
||||
_putResponseFactories[endpoint] = _ => response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers the response factory invoked when the specified PUT endpoint is called.
|
||||
/// </summary>
|
||||
/// <param name="endpoint">The API endpoint for which to register the response factory.</param>
|
||||
/// <param name="responseFactory">The factory that produces the response from the request payload.</param>
|
||||
public void RegisterPutResponseFactory(string endpoint, Func<object, object> responseFactory)
|
||||
{
|
||||
_putResponseFactories[endpoint] = responseFactory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers the specified DELETE endpoint as succeeding.
|
||||
/// </summary>
|
||||
/// <param name="endpoint">The API endpoint for which to register success.</param>
|
||||
public void RegisterDeleteSuccess(string endpoint)
|
||||
{
|
||||
_deleteSuccessEndpoints.Add(endpoint);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers the exception thrown when the specified DELETE endpoint is called.
|
||||
/// </summary>
|
||||
/// <param name="endpoint">The API endpoint for which to register the exception.</param>
|
||||
/// <param name="exception">The exception to throw.</param>
|
||||
public void RegisterDeleteException(string endpoint, ApiException exception)
|
||||
{
|
||||
_deleteExceptions[endpoint] = exception;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers the blob response returned when a blob endpoint is called.
|
||||
/// </summary>
|
||||
/// <param name="blob">The blob response to return.</param>
|
||||
public void RegisterBlobResponse(BlobDataDto blob)
|
||||
{
|
||||
_blobResponse = blob;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers the exception thrown when a blob endpoint is called.
|
||||
/// </summary>
|
||||
/// <param name="exception">The exception to throw.</param>
|
||||
public void RegisterBlobException(ApiException exception)
|
||||
{
|
||||
_blobException = exception;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers the specified POST endpoint as accepting a bodyless request without returning a response body.
|
||||
/// </summary>
|
||||
/// <param name="endpoint">The API endpoint for which to register success.</param>
|
||||
public void RegisterPostSuccess(string endpoint)
|
||||
{
|
||||
_postBodylessSuccessEndpoints.Add(endpoint);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers the specified POST endpoint as accepting a payload of type <typeparamref name="TModel"/> without returning a response body.
|
||||
/// </summary>
|
||||
/// <typeparam name="TModel">The expected type of the payload content.</typeparam>
|
||||
/// <param name="endpoint">The API endpoint for which to register the payload type.</param>
|
||||
public void RegisterPostPayload<TModel>(string endpoint)
|
||||
{
|
||||
_postPayloadTypes[endpoint] = typeof(TModel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers the specified PUT endpoint as accepting a payload of type <typeparamref name="TModel"/> without returning a response body.
|
||||
/// </summary>
|
||||
/// <typeparam name="TModel">The expected type of the payload content.</typeparam>
|
||||
/// <param name="endpoint">The API endpoint for which to register the payload type.</param>
|
||||
public void RegisterPutPayload<TModel>(string endpoint)
|
||||
{
|
||||
_putPayloadTypes[endpoint] = typeof(TModel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets all registered responses and captured requests, and restores the default authorization response.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The default authorization response is an Administrator with every permission. Tests that need a different principal must set <see cref="AuthorizationResponse"/> after calling this method.
|
||||
/// </remarks>
|
||||
public void Reset()
|
||||
{
|
||||
_getResponseFactories.Clear();
|
||||
_postResponseFactories.Clear();
|
||||
_putResponseFactories.Clear();
|
||||
_postExceptions.Clear();
|
||||
_putExceptions.Clear();
|
||||
_postBodylessSuccessEndpoints.Clear();
|
||||
_postPayloadTypes.Clear();
|
||||
_putPayloadTypes.Clear();
|
||||
_deleteSuccessEndpoints.Clear();
|
||||
_deleteExceptions.Clear();
|
||||
_blobResponse = null;
|
||||
_blobException = null;
|
||||
AuthorizationResponse = CreateDefaultAuthorizationResponse();
|
||||
AuthorizationException = null;
|
||||
GetEndpointsCalled.Clear();
|
||||
PostRequests.Clear();
|
||||
PutRequests.Clear();
|
||||
DeleteEndpointsCalled.Clear();
|
||||
BlobEndpointsCalled.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the default authorization response, an Administrator with every permission.
|
||||
/// </summary>
|
||||
/// <returns>The default authorization response.</returns>
|
||||
private static GetAuthorizationResponse CreateDefaultAuthorizationResponse()
|
||||
{
|
||||
return new(Guid.NewGuid(), "Admin", Enum.GetValues<AuthorizationPermission>());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a GET request to the specified <paramref name="endpoint"/> as an asynchronous operation and returns the result.
|
||||
/// </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="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>The deserialized response containing the result of the GET request.</returns>
|
||||
public Task<TResponse> GetAsync<TResponse>(string endpoint, CancellationToken cancellationToken = default)
|
||||
{
|
||||
GetEndpointsCalled.Add(endpoint);
|
||||
if (_getResponseFactories.TryGetValue(endpoint, out Func<object>? responseFactory))
|
||||
return Task.FromResult((TResponse)responseFactory());
|
||||
if (endpoint.StartsWith(ApiRoutes.Initialization.CHECK_INITIALIZATION, StringComparison.OrdinalIgnoreCase))
|
||||
return Task.FromResult((TResponse)(object)InitializationResponse);
|
||||
if (endpoint.Contains("auth/get-authorization", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (AuthorizationException is not null)
|
||||
throw AuthorizationException;
|
||||
return Task.FromResult((TResponse)(object)AuthorizationResponse);
|
||||
}
|
||||
throw new InvalidOperationException($"No GET response is registered for the endpoint '{endpoint}'.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a GET request to the specified <paramref name="endpoint"/> as an asynchronous operation and returns the result as a streamable response.
|
||||
/// </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="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="IAsyncEnumerable{T}"/> object, which allows for asynchronous iteration over the deserialized items.</returns>
|
||||
public async IAsyncEnumerable<TResponse?> GetAsyncEnumerable<TResponse>(string endpoint, [EnumeratorCancellation] CancellationToken cancellationToken = default)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
yield break;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a GET request to the specified <paramref name="endpoint"/> as an asynchronous operation and returns the result.
|
||||
/// </summary>
|
||||
/// <param name="endpoint">The API endpoint where the request is being sent.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>A model containing the raw blob bytes and their content type.</returns>
|
||||
public Task<BlobDataDto> GetBlobAsync(string endpoint, CancellationToken cancellationToken = default)
|
||||
{
|
||||
BlobEndpointsCalled.Add(endpoint);
|
||||
if (_blobException is not null)
|
||||
throw _blobException;
|
||||
if (_blobResponse is not null)
|
||||
return Task.FromResult(_blobResponse);
|
||||
throw new NotSupportedException("Blob retrieval is not supported by the test stub.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a DELETE request to the specified <paramref name="endpoint"/> as an asynchronous operation.
|
||||
/// </summary>
|
||||
/// <param name="endpoint">The API endpoint where the request is being sent.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public Task DeleteAsync(string endpoint, CancellationToken cancellationToken = default)
|
||||
{
|
||||
DeleteEndpointsCalled.Add(endpoint);
|
||||
if (_deleteExceptions.TryGetValue(endpoint, out ApiException? exception))
|
||||
throw exception;
|
||||
if (_deleteSuccessEndpoints.Contains(endpoint))
|
||||
return Task.CompletedTask;
|
||||
throw new ApiException(null, System.Net.HttpStatusCode.InternalServerError, endpoint);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a PUT request to the specified <paramref name="endpoint"/> as an asynchronous operation, discarding the response content.
|
||||
/// </summary>
|
||||
/// <typeparam name="TModel">The expected type of the payload content.</typeparam>
|
||||
/// <param name="endpoint">The API endpoint where the request is being sent.</param>
|
||||
/// <param name="data">The data to be serialized and sent to the API.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public Task PutIgnoringResponseAsync<TModel>(string endpoint, TModel data, CancellationToken cancellationToken = default)
|
||||
{
|
||||
PutRequests.Add((endpoint, data));
|
||||
if (_putExceptions.TryGetValue(endpoint, out ApiException? exception))
|
||||
throw exception;
|
||||
if (_putPayloadTypes.TryGetValue(endpoint, out Type? expectedType) && expectedType == typeof(TModel))
|
||||
return Task.CompletedTask;
|
||||
throw new InvalidOperationException($"No PUT payload of type '{typeof(TModel).Name}' is registered for the endpoint '{endpoint}'.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a PUT request to the specified <paramref name="endpoint"/> as an asynchronous operation and returns the result.
|
||||
/// </summary>
|
||||
/// <typeparam name="TResponse">The expected type of the response content.</typeparam>
|
||||
/// <typeparam name="TModel">The expected type of the payload content.</typeparam>
|
||||
/// <param name="endpoint">The API endpoint where the request is being sent.</param>
|
||||
/// <param name="data">The data to be serialized and sent to the API.</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> PutAsync<TResponse, TModel>(string endpoint, TModel data, CancellationToken cancellationToken = default)
|
||||
{
|
||||
PutRequests.Add((endpoint, data));
|
||||
if (_putExceptions.TryGetValue(endpoint, out ApiException? exception))
|
||||
throw exception;
|
||||
if (_putResponseFactories.TryGetValue(endpoint, out Func<object, object>? responseFactory))
|
||||
return Task.FromResult((TResponse)responseFactory(data!));
|
||||
throw new InvalidOperationException($"No PUT response is registered for the endpoint '{endpoint}'.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a PUT request with a multipart form containing a single file to the specified <paramref name="endpoint"/> as an asynchronous operation and returns the result.
|
||||
/// </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, 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)
|
||||
{
|
||||
PutRequests.Add((endpoint, fileName));
|
||||
if (_putExceptions.TryGetValue(endpoint, out ApiException? exception))
|
||||
throw exception;
|
||||
if (_putResponseFactories.TryGetValue(endpoint, out Func<object, object>? responseFactory))
|
||||
return Task.FromResult((TResponse)responseFactory(fileName));
|
||||
throw new InvalidOperationException($"No PUT response is registered for the endpoint '{endpoint}'.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a POST request with a multipart form containing a single file to the specified <paramref name="endpoint"/> as an asynchronous operation and returns the result.
|
||||
/// </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="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 POST request.</returns>
|
||||
public Task<TResponse> PostMultipartAsync<TResponse>(string endpoint, Stream fileStream, string fileName, string fieldName, CancellationToken cancellationToken = default)
|
||||
{
|
||||
PostRequests.Add((endpoint, fileName));
|
||||
if (_postExceptions.TryGetValue(endpoint, out ApiException? exception))
|
||||
throw exception;
|
||||
if (_postResponseFactories.TryGetValue(endpoint, out Func<object, object>? responseFactory))
|
||||
return Task.FromResult((TResponse)responseFactory(fileName));
|
||||
throw new InvalidOperationException($"No POST response is registered for the endpoint '{endpoint}'.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a POST request without a payload to the specified <paramref name="endpoint"/> as an asynchronous operation, discarding the response content.
|
||||
/// </summary>
|
||||
/// <param name="endpoint">The API endpoint where the request is being sent.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public Task PostIgnoringResponseAsync(string endpoint, CancellationToken cancellationToken = default)
|
||||
{
|
||||
PostRequests.Add((endpoint, null));
|
||||
if (_postExceptions.TryGetValue(endpoint, out ApiException? exception))
|
||||
throw exception;
|
||||
if (_postBodylessSuccessEndpoints.Contains(endpoint))
|
||||
return Task.CompletedTask;
|
||||
throw new InvalidOperationException($"No bodyless POST success is registered for the endpoint '{endpoint}'.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a POST request without a payload to the specified <paramref name="endpoint"/> as an asynchronous operation and returns the result.
|
||||
/// </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="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>The registered response.</returns>
|
||||
public Task<TResponse> PostAsync<TResponse>(string endpoint, CancellationToken cancellationToken = default)
|
||||
{
|
||||
PostRequests.Add((endpoint, null));
|
||||
if (_postExceptions.TryGetValue(endpoint, out ApiException? exception))
|
||||
throw exception;
|
||||
if (_postResponseFactories.TryGetValue(endpoint, out Func<object, object>? responseFactory))
|
||||
return Task.FromResult((TResponse)responseFactory(new object()));
|
||||
if (endpoint == ApiRoutes.Authentication.LOGIN_ACCOUNT)
|
||||
return Task.FromResult((TResponse)(object)LoginResponse);
|
||||
throw new InvalidOperationException($"No POST response is registered for the endpoint '{endpoint}'.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a POST request to the specified <paramref name="endpoint"/> as an asynchronous operation, discarding the response content.
|
||||
/// </summary>
|
||||
/// <typeparam name="TModel">The expected type of the payload content.</typeparam>
|
||||
/// <param name="endpoint">The API endpoint where the request is being sent.</param>
|
||||
/// <param name="data">The data to be serialized and sent to the API.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public Task PostIgnoringResponseAsync<TModel>(string endpoint, TModel data, CancellationToken cancellationToken = default)
|
||||
{
|
||||
PostRequests.Add((endpoint, data));
|
||||
if (_postExceptions.TryGetValue(endpoint, out ApiException? exception))
|
||||
throw exception;
|
||||
if (_postPayloadTypes.TryGetValue(endpoint, out Type? expectedType) && expectedType == typeof(TModel))
|
||||
return Task.CompletedTask;
|
||||
throw new InvalidOperationException($"No POST payload of type '{typeof(TModel).Name}' is registered for the endpoint '{endpoint}'.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a POST request to the specified <paramref name="endpoint"/> as an asynchronous operation and returns the result.
|
||||
/// </summary>
|
||||
/// <typeparam name="TResponse">The expected type of the response content.</typeparam>
|
||||
/// <typeparam name="TModel">The expected type of the payload content.</typeparam>
|
||||
/// <param name="endpoint">The API endpoint where the request is being sent.</param>
|
||||
/// <param name="data">The data to be serialized and sent to the API.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>The deserialized response containing the result of the POST request.</returns>
|
||||
public Task<TResponse> PostAsync<TResponse, TModel>(string endpoint, TModel data, CancellationToken cancellationToken = default)
|
||||
{
|
||||
PostRequests.Add((endpoint, data));
|
||||
if (_postExceptions.TryGetValue(endpoint, out ApiException? exception))
|
||||
throw exception;
|
||||
if (_postResponseFactories.TryGetValue(endpoint, out Func<object, object>? responseFactory))
|
||||
return Task.FromResult((TResponse)responseFactory(data!));
|
||||
if (endpoint == ApiRoutes.Authentication.LOGIN_ACCOUNT)
|
||||
return Task.FromResult((TResponse)(object)LoginResponse);
|
||||
throw new InvalidOperationException($"No POST response is registered for the endpoint '{endpoint}'.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Api;
|
||||
|
||||
/// <summary>
|
||||
/// A streamed request that was sent to the <see cref="StubStreamingApiHttpClient"/> stub.
|
||||
/// </summary>
|
||||
/// <param name="Endpoint">The endpoint the stream was requested from.</param>
|
||||
/// <param name="Headers">The request headers that were forwarded with the request.</param>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public record StubStreamRequest(string Endpoint, IReadOnlyDictionary<string, string> Headers);
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Api;
|
||||
|
||||
/// <summary>
|
||||
/// Test double for the <see cref="IStreamingApiHttpClient"/> interface, allowing integration and security tests to stub the
|
||||
/// streamed responses of the remote API without hosting a real backend.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class StubStreamingApiHttpClient : IStreamingApiHttpClient
|
||||
{
|
||||
private readonly Dictionary<string, Func<ApiStreamResult>> _streamResponseFactories = [];
|
||||
private readonly Dictionary<string, Func<Exception>> _streamExceptionFactories = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the streamed requests that were sent, with the headers that were forwarded with them.
|
||||
/// </summary>
|
||||
public List<StubStreamRequest> StreamRequests { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of endpoints the streams were requested from.
|
||||
/// </summary>
|
||||
public List<string> GetEndpointsCalled { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Registers the streamed response returned when the specified endpoint is called.
|
||||
/// </summary>
|
||||
/// <param name="endpoint">The API endpoint for which to register the response.</param>
|
||||
/// <param name="response">The streamed response to return.</param>
|
||||
public void RegisterStreamResponse(string endpoint, ApiStreamResult response)
|
||||
{
|
||||
_streamResponseFactories[endpoint] = () => response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers the response factory invoked when the specified endpoint is called.
|
||||
/// </summary>
|
||||
/// <param name="endpoint">The API endpoint for which to register the response factory.</param>
|
||||
/// <param name="responseFactory">The factory that produces the streamed response.</param>
|
||||
public void RegisterStreamResponseFactory(string endpoint, Func<ApiStreamResult> responseFactory)
|
||||
{
|
||||
_streamResponseFactories[endpoint] = responseFactory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers the exception thrown when the specified endpoint is called.
|
||||
/// </summary>
|
||||
/// <param name="endpoint">The API endpoint for which to register the exception.</param>
|
||||
/// <param name="exception">The exception to throw.</param>
|
||||
public void RegisterStreamException(string endpoint, Exception exception)
|
||||
{
|
||||
_streamExceptionFactories[endpoint] = () => exception;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets all registered responses and captured requests.
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
_streamResponseFactories.Clear();
|
||||
_streamExceptionFactories.Clear();
|
||||
StreamRequests.Clear();
|
||||
GetEndpointsCalled.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a GET request to the specified <paramref name="endpoint"/> as an asynchronous operation and returns the response as a stream.
|
||||
/// </summary>
|
||||
/// <param name="endpoint">The API endpoint where the request is being sent.</param>
|
||||
/// <param name="requestHeaders">The range and conditional headers of the incoming request to forward.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>The streamed response of the API request.</returns>
|
||||
public Task<ApiStreamResult> GetStreamAsync(string endpoint, IReadOnlyDictionary<string, string> requestHeaders, CancellationToken cancellationToken = default)
|
||||
{
|
||||
GetEndpointsCalled.Add(endpoint);
|
||||
StreamRequests.Add(new StubStreamRequest(endpoint, new Dictionary<string, string>(requestHeaders)));
|
||||
if (_streamExceptionFactories.TryGetValue(endpoint, out Func<Exception>? exceptionFactory))
|
||||
throw exceptionFactory();
|
||||
if (_streamResponseFactories.TryGetValue(endpoint, out Func<ApiStreamResult>? responseFactory))
|
||||
return Task.FromResult(responseFactory());
|
||||
throw new InvalidOperationException($"No stream response is registered for the endpoint '{endpoint}'.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Api;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="HttpMessageHandler"/> test double that returns a configurable response for every request sent through it.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class TestApiHttpMessageHandler : HttpMessageHandler
|
||||
{
|
||||
private readonly Func<HttpRequestMessage, CancellationToken, Task<HttpResponseMessage>> _responseFactory;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of requests that were sent through this handler.
|
||||
/// </summary>
|
||||
public List<HttpRequestMessage> Requests { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the bodies of the requests that were sent through this handler, captured while the request content is still available.
|
||||
/// </summary>
|
||||
public List<string?> RequestBodies { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the cancellation tokens the requests were sent with.
|
||||
/// </summary>
|
||||
public List<CancellationToken> CancellationTokens { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TestApiHttpMessageHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="responseFactory">The factory that produces the response for a given request.</param>
|
||||
public TestApiHttpMessageHandler(Func<HttpRequestMessage, HttpResponseMessage> responseFactory)
|
||||
{
|
||||
_responseFactory = (request, cancellationToken) => Task.FromResult(responseFactory(request));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TestApiHttpMessageHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="responseFactory">The asynchronous factory that produces the response for a given request and cancellation token.</param>
|
||||
public TestApiHttpMessageHandler(Func<HttpRequestMessage, CancellationToken, Task<HttpResponseMessage>> responseFactory)
|
||||
{
|
||||
_responseFactory = responseFactory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends the request to the configured response factory.
|
||||
/// </summary>
|
||||
/// <param name="request">The HTTP request message to send.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>The configured HTTP response message.</returns>
|
||||
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
||||
{
|
||||
Requests.Add(request);
|
||||
CancellationTokens.Add(cancellationToken);
|
||||
RequestBodies.Add(request.Content is null ? null : await request.Content.ReadAsStringAsync(cancellationToken));
|
||||
return await _responseFactory(request, cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Api;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="HttpContent"/> test double that exposes whether the client buffered the content before handing it to the caller,
|
||||
/// whether the content was disposed, and whether obtaining its stream is allowed to fail.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public sealed class TrackingStreamContent : HttpContent
|
||||
{
|
||||
private readonly byte[] _contentBytes;
|
||||
private readonly MemoryStream _contentStream;
|
||||
private readonly bool _shouldFailStreamCreation;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the content was buffered by the client before it was handed to the caller.
|
||||
/// </summary>
|
||||
public bool WasBufferedByClient { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the content was disposed.
|
||||
/// </summary>
|
||||
public bool IsDisposed { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the stream the content hands over when it is read without being buffered first.
|
||||
/// </summary>
|
||||
public Stream ContentStream => _contentStream;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TrackingStreamContent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="contentBytes">The bytes of the content.</param>
|
||||
/// <param name="mediaType">The media type the content declares.</param>
|
||||
/// <param name="shouldFailStreamCreation">Whether obtaining the content stream should fail.</param>
|
||||
public TrackingStreamContent(byte[] contentBytes, string mediaType = "application/octet-stream", bool shouldFailStreamCreation = false)
|
||||
{
|
||||
_contentBytes = contentBytes;
|
||||
_contentStream = new MemoryStream(contentBytes);
|
||||
_shouldFailStreamCreation = shouldFailStreamCreation;
|
||||
Headers.ContentType = new MediaTypeHeaderValue(mediaType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the content to the provided stream, recording that the client buffered it.
|
||||
/// </summary>
|
||||
/// <param name="stream">The stream the content is written to.</param>
|
||||
/// <param name="context">The transport context of the serialization, if any.</param>
|
||||
/// <returns>A task that represents the asynchronous serialization.</returns>
|
||||
protected override Task SerializeToStreamAsync(Stream stream, TransportContext? context)
|
||||
{
|
||||
WasBufferedByClient = true;
|
||||
return stream.WriteAsync(_contentBytes, 0, _contentBytes.Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hands over the known content stream without buffering the content first.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>The content stream.</returns>
|
||||
/// <exception cref="InvalidOperationException">Thrown when the content is configured to fail obtaining its stream.</exception>
|
||||
protected override Task<Stream> CreateContentReadStreamAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
if (_shouldFailStreamCreation)
|
||||
throw new InvalidOperationException("The content stream cannot be obtained.");
|
||||
return Task.FromResult<Stream>(_contentStream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Computes the length of the content.
|
||||
/// </summary>
|
||||
/// <param name="length">The length of the content in bytes.</param>
|
||||
/// <returns>Always <see langword="true"/>.</returns>
|
||||
protected override bool TryComputeLength(out long length)
|
||||
{
|
||||
length = _contentBytes.Length;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes the content, recording that it was disposed.
|
||||
/// </summary>
|
||||
/// <param name="disposing">Whether the content is being disposed.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
IsDisposed = true;
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary;
|
||||
using Lumina.Presentation.Web.Common.Enums.AudioLibrary;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AudioRatingDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AudioRatingDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="AudioRatingDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The numeric value of the rating.</param>
|
||||
/// <param name="maxValue">Optional. The maximum possible rating value.</param>
|
||||
/// <param name="voteCount">Optional. The number of votes the rating is based on.</param>
|
||||
/// <param name="source">Optional. The source of the audio rating.</param>
|
||||
/// <param name="includeValue">Whether the value should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeMaxValue">Whether the maximum value should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeVoteCount">Whether the vote count should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeSource">Whether the source should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="AudioRatingDto"/> instance.</returns>
|
||||
public AudioRatingDto Create(
|
||||
decimal? value = null,
|
||||
decimal? maxValue = null,
|
||||
int? voteCount = null,
|
||||
AudioRatingSource? source = null,
|
||||
bool includeValue = true,
|
||||
bool includeMaxValue = true,
|
||||
bool includeVoteCount = true,
|
||||
bool includeSource = true)
|
||||
{
|
||||
return new AudioRatingDto
|
||||
{
|
||||
Value = includeValue ? (value ?? _faker.Random.Decimal(1, 5)) : null,
|
||||
MaxValue = includeMaxValue ? (maxValue ?? 5) : null,
|
||||
VoteCount = includeVoteCount ? (voteCount ?? _faker.Random.Number(1, 1000)) : null,
|
||||
Source = includeSource ? (source ?? _faker.PickRandom<AudioRatingSource>()) : null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="AudioRatingDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="AudioRatingDto"/> instances.</returns>
|
||||
public List<AudioRatingDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="DeletedMusicAlbumDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class DeletedMusicAlbumDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="DeletedMusicAlbumDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the deleted album.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library the deleted album belongs to.</param>
|
||||
/// <param name="artistId">Optional. The Id of the artist the deleted album belongs to.</param>
|
||||
/// <param name="artistName">Optional. The name of the artist the deleted album belongs to.</param>
|
||||
/// <param name="title">Optional. The title of the deleted album.</param>
|
||||
/// <param name="deletedOnUtc">Optional. The date and time when the album was deleted.</param>
|
||||
/// <param name="coverPath">Optional. The relative path of the stored cover image of the deleted album.</param>
|
||||
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="DeletedMusicAlbumDto"/>.</returns>
|
||||
public DeletedMusicAlbumDto Create(
|
||||
Guid? id = null,
|
||||
Guid? libraryId = null,
|
||||
Guid? artistId = null,
|
||||
string? artistName = null,
|
||||
string? title = null,
|
||||
DateTime? deletedOnUtc = null,
|
||||
string? coverPath = null,
|
||||
bool includeCoverPath = true)
|
||||
{
|
||||
return new DeletedMusicAlbumDto(
|
||||
Id: id ?? _faker.Random.Guid(),
|
||||
LibraryId: libraryId ?? _faker.Random.Guid(),
|
||||
ArtistId: artistId ?? _faker.Random.Guid(),
|
||||
ArtistName: artistName ?? _faker.Lorem.Word(),
|
||||
Title: title ?? _faker.Lorem.Sentence(),
|
||||
DeletedOnUtc: deletedOnUtc ?? _faker.Date.Recent(),
|
||||
CoverPath: includeCoverPath ? (coverPath ?? _faker.System.FilePath()) : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="DeletedMusicAlbumDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="DeletedMusicAlbumDto"/> instances.</returns>
|
||||
public List<DeletedMusicAlbumDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="DeletedMusicArtistDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class DeletedMusicArtistDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="DeletedMusicArtistDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the deleted artist.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library the deleted artist belongs to.</param>
|
||||
/// <param name="name">Optional. The name of the deleted artist.</param>
|
||||
/// <param name="deletedOnUtc">Optional. The date and time when the artist was deleted.</param>
|
||||
/// <param name="coverPath">Optional. The relative path of the stored cover image of the deleted artist.</param>
|
||||
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="DeletedMusicArtistDto"/>.</returns>
|
||||
public DeletedMusicArtistDto Create(
|
||||
Guid? id = null,
|
||||
Guid? libraryId = null,
|
||||
string? name = null,
|
||||
DateTime? deletedOnUtc = null,
|
||||
string? coverPath = null,
|
||||
bool includeCoverPath = true)
|
||||
{
|
||||
return new DeletedMusicArtistDto(
|
||||
Id: id ?? _faker.Random.Guid(),
|
||||
LibraryId: libraryId ?? _faker.Random.Guid(),
|
||||
Name: name ?? _faker.Lorem.Word(),
|
||||
DeletedOnUtc: deletedOnUtc ?? _faker.Date.Recent(),
|
||||
CoverPath: includeCoverPath ? (coverPath ?? _faker.System.FilePath()) : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="DeletedMusicArtistDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="DeletedMusicArtistDto"/> instances.</returns>
|
||||
public List<DeletedMusicArtistDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="DeletedMusicItemsPageDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class DeletedMusicItemsPageDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly LibraryDtoFixture _libraryDtoFixture = new();
|
||||
private readonly DeletedMusicArtistDtoFixture _deletedMusicArtistDtoFixture = new();
|
||||
private readonly DeletedMusicAlbumDtoFixture _deletedMusicAlbumDtoFixture = new();
|
||||
private readonly DeletedMusicTrackDtoFixture _deletedMusicTrackDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="DeletedMusicItemsPageDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="library">Optional. The media library whose deleted music items are shown.</param>
|
||||
/// <param name="deletedArtists">Optional. The deleted artists of the media library.</param>
|
||||
/// <param name="deletedAlbums">Optional. The deleted albums of the media library.</param>
|
||||
/// <param name="deletedTracks">Optional. The deleted tracks of the media library.</param>
|
||||
/// <returns>The created <see cref="DeletedMusicItemsPageDto"/>.</returns>
|
||||
public DeletedMusicItemsPageDto Create(
|
||||
LibraryDto? library = null,
|
||||
IReadOnlyList<DeletedMusicArtistDto>? deletedArtists = null,
|
||||
IReadOnlyList<DeletedMusicAlbumDto>? deletedAlbums = null,
|
||||
IReadOnlyList<DeletedMusicTrackDto>? deletedTracks = null)
|
||||
{
|
||||
return new DeletedMusicItemsPageDto(
|
||||
Library: library ?? _libraryDtoFixture.Create(),
|
||||
DeletedArtists: deletedArtists ?? _deletedMusicArtistDtoFixture.CreateMany(_faker.Random.Number(1, 3)),
|
||||
DeletedAlbums: deletedAlbums ?? _deletedMusicAlbumDtoFixture.CreateMany(_faker.Random.Number(1, 3)),
|
||||
DeletedTracks: deletedTracks ?? _deletedMusicTrackDtoFixture.CreateMany(_faker.Random.Number(1, 3))
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="DeletedMusicItemsPageDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="DeletedMusicItemsPageDto"/> instances.</returns>
|
||||
public List<DeletedMusicItemsPageDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="DeletedMusicTrackDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class DeletedMusicTrackDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="DeletedMusicTrackDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the deleted track.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library the deleted track belongs to.</param>
|
||||
/// <param name="artistId">Optional. The Id of the artist the deleted track belongs to.</param>
|
||||
/// <param name="artistName">Optional. The name of the artist the deleted track belongs to.</param>
|
||||
/// <param name="albumId">Optional. The Id of the album the deleted track belongs to.</param>
|
||||
/// <param name="albumTitle">Optional. The title of the album the deleted track belongs to.</param>
|
||||
/// <param name="title">Optional. The title of the deleted track.</param>
|
||||
/// <param name="path">Optional. The file system path of the deleted track.</param>
|
||||
/// <param name="deletedOnUtc">Optional. The date and time when the track was deleted.</param>
|
||||
/// <returns>The created <see cref="DeletedMusicTrackDto"/>.</returns>
|
||||
public DeletedMusicTrackDto Create(
|
||||
Guid? id = null,
|
||||
Guid? libraryId = null,
|
||||
Guid? artistId = null,
|
||||
string? artistName = null,
|
||||
Guid? albumId = null,
|
||||
string? albumTitle = null,
|
||||
string? title = null,
|
||||
string? path = null,
|
||||
DateTime? deletedOnUtc = null)
|
||||
{
|
||||
return new DeletedMusicTrackDto(
|
||||
Id: id ?? _faker.Random.Guid(),
|
||||
LibraryId: libraryId ?? _faker.Random.Guid(),
|
||||
ArtistId: artistId ?? _faker.Random.Guid(),
|
||||
ArtistName: artistName ?? _faker.Lorem.Word(),
|
||||
AlbumId: albumId ?? _faker.Random.Guid(),
|
||||
AlbumTitle: albumTitle ?? _faker.Lorem.Sentence(),
|
||||
Title: title ?? _faker.Lorem.Sentence(),
|
||||
Path: path ?? _faker.System.FilePath(),
|
||||
DeletedOnUtc: deletedOnUtc ?? _faker.Date.Recent()
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="DeletedMusicTrackDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="DeletedMusicTrackDto"/> instances.</returns>
|
||||
public List<DeletedMusicTrackDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="IsrcDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class IsrcDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="IsrcDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The value of the ISRC.</param>
|
||||
/// <param name="includeValue">Whether the value should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="IsrcDto"/> instance.</returns>
|
||||
public IsrcDto Create(
|
||||
string? value = null,
|
||||
bool includeValue = true)
|
||||
{
|
||||
return new IsrcDto
|
||||
{
|
||||
Value = includeValue ? (value ?? $"US{_faker.Random.String2(3, "ABCDEFGHIJKLMNOPQRSTUVWXYZ")}{_faker.Random.Number(10000, 99999)}") : null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="IsrcDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="IsrcDto"/> instances.</returns>
|
||||
public List<IsrcDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary;
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.DTO.MediaContributors;
|
||||
using Lumina.Presentation.Web.Common.Enums.AudioLibrary;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.MediaContributors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MusicAlbumDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MusicAlbumDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly MusicAlbumMetadataDtoFixture _musicAlbumMetadataDtoFixture = new();
|
||||
private readonly MediaArtworkDtoFixture _mediaArtworkDtoFixture = new();
|
||||
private readonly MusicTrackDtoFixture _musicTrackDtoFixture = new();
|
||||
private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new();
|
||||
private readonly AudioRatingDtoFixture _audioRatingDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="MusicAlbumDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the album.</param>
|
||||
/// <param name="artistId">Optional. The Id of the artist the album belongs to.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library this album belongs to.</param>
|
||||
/// <param name="coverPath">Optional. The path of the image representing the album.</param>
|
||||
/// <param name="artwork">Optional. The stored artwork of the album.</param>
|
||||
/// <param name="metadata">Optional. The album metadata of the album.</param>
|
||||
/// <param name="mediaFormat">Optional. The physical or digital medium of the album.</param>
|
||||
/// <param name="packaging">Optional. The outermost physical packaging of the album.</param>
|
||||
/// <param name="barcode">Optional. The barcode of the album.</param>
|
||||
/// <param name="catalogNumbers">Optional. The catalog numbers of the album.</param>
|
||||
/// <param name="label">Optional. The name of the label that issued the album.</param>
|
||||
/// <param name="asin">Optional. The ASIN of the album.</param>
|
||||
/// <param name="musicBrainzReleaseId">Optional. The MusicBrainz identifier of the release.</param>
|
||||
/// <param name="musicBrainzReleaseGroupId">Optional. The MusicBrainz identifier of the release group.</param>
|
||||
/// <param name="musicBrainzReleaseArtistId">Optional. The MusicBrainz identifier of the release artist.</param>
|
||||
/// <param name="createdOnUtc">Optional. The date and time when the album was created.</param>
|
||||
/// <param name="updatedOnUtc">Optional. The date and time when the album was updated.</param>
|
||||
/// <param name="contributors">Optional. The references to the media contributors that performed on the album.</param>
|
||||
/// <param name="ratings">Optional. The ratings of the album.</param>
|
||||
/// <param name="tracks">Optional. The tracks of the album.</param>
|
||||
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeArtwork">Whether the artwork should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeMetadata">Whether the metadata should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeMediaFormat">Whether the media format should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includePackaging">Whether the packaging should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeBarcode">Whether the barcode should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeCatalogNumbers">Whether the catalog numbers should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeLabel">Whether the label should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeAsin">Whether the ASIN should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeMusicBrainzReleaseId">Whether the MusicBrainz release Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeMusicBrainzReleaseGroupId">Whether the MusicBrainz release group Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeMusicBrainzReleaseArtistId">Whether the MusicBrainz release artist Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the update date should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeContributors">Whether the contributors should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeRatings">Whether the ratings should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeTracks">Whether the tracks should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="MusicAlbumDto"/> instance.</returns>
|
||||
public MusicAlbumDto Create(
|
||||
Guid? id = null,
|
||||
Guid? artistId = null,
|
||||
Guid? libraryId = null,
|
||||
string? coverPath = null,
|
||||
List<MediaArtworkDto>? artwork = null,
|
||||
MusicAlbumMetadataDto? metadata = null,
|
||||
MusicMediaFormat? mediaFormat = null,
|
||||
MusicReleasePackaging? packaging = null,
|
||||
string? barcode = null,
|
||||
List<string>? catalogNumbers = null,
|
||||
string? label = null,
|
||||
string? asin = null,
|
||||
Guid? musicBrainzReleaseId = null,
|
||||
Guid? musicBrainzReleaseGroupId = null,
|
||||
Guid? musicBrainzReleaseArtistId = null,
|
||||
DateTime? createdOnUtc = null,
|
||||
DateTime? updatedOnUtc = null,
|
||||
List<MediaContributorReferenceDto>? contributors = null,
|
||||
List<AudioRatingDto>? ratings = null,
|
||||
List<MusicTrackDto>? tracks = null,
|
||||
bool includeCoverPath = true,
|
||||
bool includeArtwork = true,
|
||||
bool includeMetadata = true,
|
||||
bool includeMediaFormat = true,
|
||||
bool includePackaging = true,
|
||||
bool includeBarcode = true,
|
||||
bool includeCatalogNumbers = true,
|
||||
bool includeLabel = true,
|
||||
bool includeAsin = true,
|
||||
bool includeMusicBrainzReleaseId = true,
|
||||
bool includeMusicBrainzReleaseGroupId = true,
|
||||
bool includeMusicBrainzReleaseArtistId = true,
|
||||
bool includeUpdatedOnUtc = true,
|
||||
bool includeContributors = true,
|
||||
bool includeRatings = true,
|
||||
bool includeTracks = true)
|
||||
{
|
||||
return new MusicAlbumDto
|
||||
{
|
||||
Id = id ?? _faker.Random.Guid(),
|
||||
ArtistId = artistId ?? _faker.Random.Guid(),
|
||||
LibraryId = libraryId ?? _faker.Random.Guid(),
|
||||
CoverPath = includeCoverPath ? (coverPath ?? _faker.System.FilePath()) : null,
|
||||
Artwork = includeArtwork ? (artwork ?? [.. _mediaArtworkDtoFixture.CreateMany(_faker.Random.Number(1, 3))]) : null,
|
||||
Metadata = includeMetadata ? (metadata ?? _musicAlbumMetadataDtoFixture.Create()) : null,
|
||||
MediaFormat = includeMediaFormat ? (mediaFormat ?? _faker.PickRandom<MusicMediaFormat>()) : null,
|
||||
Packaging = includePackaging ? (packaging ?? _faker.PickRandom<MusicReleasePackaging>()) : null,
|
||||
Barcode = includeBarcode ? (barcode ?? _faker.Random.String2(13, "0123456789")) : null,
|
||||
CatalogNumbers = includeCatalogNumbers ? (catalogNumbers ?? [.. Enumerable.Range(0, _faker.Random.Number(1, 3)).Select(_ => _faker.Random.String2(10))]) : null,
|
||||
Label = includeLabel ? (label ?? _faker.Company.CompanyName()) : null,
|
||||
ASIN = includeAsin ? (asin ?? _faker.Random.String2(10)) : null,
|
||||
MusicBrainzReleaseId = includeMusicBrainzReleaseId ? (musicBrainzReleaseId ?? _faker.Random.Guid()) : null,
|
||||
MusicBrainzReleaseGroupId = includeMusicBrainzReleaseGroupId ? (musicBrainzReleaseGroupId ?? _faker.Random.Guid()) : null,
|
||||
MusicBrainzReleaseArtistId = includeMusicBrainzReleaseArtistId ? (musicBrainzReleaseArtistId ?? _faker.Random.Guid()) : null,
|
||||
CreatedOnUtc = createdOnUtc ?? _faker.Date.Past(),
|
||||
UpdatedOnUtc = includeUpdatedOnUtc ? (updatedOnUtc ?? _faker.Date.Recent()) : null,
|
||||
Contributors = includeContributors ? (contributors ?? [.. _mediaContributorReferenceDtoFixture.CreateMany(_faker.Random.Number(1, 3))]) : null,
|
||||
Ratings = includeRatings ? (ratings ?? [.. _audioRatingDtoFixture.CreateMany(_faker.Random.Number(1, 3))]) : null,
|
||||
Tracks = includeTracks ? (tracks ?? [.. _musicTrackDtoFixture.CreateMany(_faker.Random.Number(1, 3))]) : null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MusicAlbumDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MusicAlbumDto"/> instances.</returns>
|
||||
public List<MusicAlbumDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Presentation.Web.Common.Enums.AudioLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MusicAlbumLiteDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MusicAlbumLiteDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="MusicAlbumLiteDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the album.</param>
|
||||
/// <param name="title">Optional. The title of the album.</param>
|
||||
/// <param name="totalTracks">Optional. The number of tracks of the release.</param>
|
||||
/// <param name="coverPath">Optional. The path of the image representing the album.</param>
|
||||
/// <param name="releaseYear">Optional. The release year of the album.</param>
|
||||
/// <param name="releaseTypes">Optional. The set of types of the release.</param>
|
||||
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeReleaseYear">Whether the release year should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeReleaseTypes">Whether the release types should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="MusicAlbumLiteDto"/> instance.</returns>
|
||||
public MusicAlbumLiteDto Create(
|
||||
Guid? id = null,
|
||||
string? title = null,
|
||||
int? totalTracks = null,
|
||||
string? coverPath = null,
|
||||
int? releaseYear = null,
|
||||
List<MusicReleaseType>? releaseTypes = null,
|
||||
bool includeCoverPath = true,
|
||||
bool includeReleaseYear = true,
|
||||
bool includeReleaseTypes = true)
|
||||
{
|
||||
return new MusicAlbumLiteDto
|
||||
{
|
||||
Id = id ?? _faker.Random.Guid(),
|
||||
Title = title ?? _faker.Lorem.Sentence(3),
|
||||
TotalTracks = totalTracks ?? _faker.Random.Number(1, 30),
|
||||
CoverPath = includeCoverPath ? (coverPath ?? _faker.System.FilePath()) : null,
|
||||
ReleaseYear = includeReleaseYear ? (releaseYear ?? Random.Shared.Next(1900, 2026)) : null,
|
||||
ReleaseTypes = includeReleaseTypes ? (releaseTypes ?? [.. Enumerable.Range(0, _faker.Random.Number(1, 3)).Select(_ => _faker.PickRandom<MusicReleaseType>())]) : null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MusicAlbumLiteDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MusicAlbumLiteDto"/> instances.</returns>
|
||||
public List<MusicAlbumLiteDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.Enums.AudioLibrary;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.Common;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MusicAlbumMetadataDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MusicAlbumMetadataDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly ReleaseInfoDtoFixture _releaseInfoDtoFixture = new();
|
||||
private readonly LanguageInfoDtoFixture _languageInfoDtoFixture = new();
|
||||
private readonly TagDtoFixture _tagDtoFixture = new();
|
||||
private readonly GenreDtoFixture _genreDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="MusicAlbumMetadataDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="title">Optional. The title of the album.</param>
|
||||
/// <param name="originalTitle">Optional. The original title of the album.</param>
|
||||
/// <param name="description">Optional. A brief description of the album.</param>
|
||||
/// <param name="disambiguation">Optional. The disambiguation comment of the album.</param>
|
||||
/// <param name="releaseInfo">Optional. The release information of the album.</param>
|
||||
/// <param name="language">Optional. The language of the album.</param>
|
||||
/// <param name="originalLanguage">Optional. The original language of the album.</param>
|
||||
/// <param name="tags">Optional. The tags that describe or categorize the album.</param>
|
||||
/// <param name="genres">Optional. The genres associated with the album.</param>
|
||||
/// <param name="script">Optional. The script used by the language of the release of the album.</param>
|
||||
/// <param name="releaseTypes">Optional. The set of types of the release.</param>
|
||||
/// <param name="releaseStatus">Optional. The status of the release.</param>
|
||||
/// <param name="totalDiscs">Optional. The number of discs of the release.</param>
|
||||
/// <param name="totalTracks">Optional. The number of tracks of the release.</param>
|
||||
/// <param name="releaseTitle">Optional. The title of the specific release the album files match.</param>
|
||||
/// <param name="includeTitle">Whether the title should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeOriginalTitle">Whether the original title should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeDescription">Whether the description should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeDisambiguation">Whether the disambiguation should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeReleaseInfo">Whether the release information should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeLanguage">Whether the language should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeOriginalLanguage">Whether the original language should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeTags">Whether the tags should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeGenres">Whether the genres should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeScript">Whether the script should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeReleaseTypes">Whether the release types should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeReleaseStatus">Whether the release status should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeTotalDiscs">Whether the total number of discs should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeTotalTracks">Whether the total number of tracks should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeReleaseTitle">Whether the release title should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="MusicAlbumMetadataDto"/> instance.</returns>
|
||||
public MusicAlbumMetadataDto Create(
|
||||
string? title = null,
|
||||
string? originalTitle = null,
|
||||
string? description = null,
|
||||
string? disambiguation = null,
|
||||
ReleaseInfoDto? releaseInfo = null,
|
||||
LanguageInfoDto? language = null,
|
||||
LanguageInfoDto? originalLanguage = null,
|
||||
List<TagDto>? tags = null,
|
||||
List<GenreDto>? genres = null,
|
||||
string? script = null,
|
||||
List<MusicReleaseType>? releaseTypes = null,
|
||||
MusicReleaseStatus? releaseStatus = null,
|
||||
int? totalDiscs = null,
|
||||
int? totalTracks = null,
|
||||
string? releaseTitle = null,
|
||||
bool includeTitle = true,
|
||||
bool includeOriginalTitle = true,
|
||||
bool includeDescription = true,
|
||||
bool includeDisambiguation = true,
|
||||
bool includeReleaseInfo = true,
|
||||
bool includeLanguage = true,
|
||||
bool includeOriginalLanguage = true,
|
||||
bool includeTags = true,
|
||||
bool includeGenres = true,
|
||||
bool includeScript = true,
|
||||
bool includeReleaseTypes = true,
|
||||
bool includeReleaseStatus = true,
|
||||
bool includeTotalDiscs = true,
|
||||
bool includeTotalTracks = true,
|
||||
bool includeReleaseTitle = true)
|
||||
{
|
||||
return new MusicAlbumMetadataDto
|
||||
{
|
||||
Title = includeTitle ? (title ?? _faker.Lorem.Sentence(3)) : null,
|
||||
OriginalTitle = includeOriginalTitle ? (originalTitle ?? _faker.Lorem.Sentence(3)) : null,
|
||||
Description = includeDescription ? (description ?? _faker.Lorem.Paragraph()) : null,
|
||||
Disambiguation = includeDisambiguation ? (disambiguation ?? _faker.Lorem.Word()) : null,
|
||||
ReleaseInfo = includeReleaseInfo ? (releaseInfo ?? _releaseInfoDtoFixture.Create()) : null,
|
||||
Language = includeLanguage ? (language ?? _languageInfoDtoFixture.Create()) : null,
|
||||
OriginalLanguage = includeOriginalLanguage ? (originalLanguage ?? _languageInfoDtoFixture.Create()) : null,
|
||||
Tags = includeTags ? (tags ?? [.. _tagDtoFixture.CreateMany(_faker.Random.Number(1, 3))]) : null,
|
||||
Genres = includeGenres ? (genres ?? [.. _genreDtoFixture.CreateMany(_faker.Random.Number(1, 3))]) : null,
|
||||
Script = includeScript ? (script ?? _faker.Lorem.Word()) : null,
|
||||
ReleaseTypes = includeReleaseTypes ? (releaseTypes ?? [.. Enumerable.Range(0, _faker.Random.Number(1, 3)).Select(_ => _faker.PickRandom<MusicReleaseType>())]) : null,
|
||||
ReleaseStatus = includeReleaseStatus ? (releaseStatus ?? _faker.PickRandom<MusicReleaseStatus>()) : null,
|
||||
TotalDiscs = includeTotalDiscs ? (totalDiscs ?? _faker.Random.Number(1, 4)) : null,
|
||||
TotalTracks = includeTotalTracks ? (totalTracks ?? _faker.Random.Number(1, 30)) : null,
|
||||
ReleaseTitle = includeReleaseTitle ? (releaseTitle ?? _faker.Lorem.Sentence(3)) : null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MusicAlbumMetadataDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MusicAlbumMetadataDto"/> instances.</returns>
|
||||
public List<MusicAlbumMetadataDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MusicAreaDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MusicAreaDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="MusicAreaDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="musicBrainzAreaId">Optional. The MusicBrainz identifier of the area.</param>
|
||||
/// <param name="name">Optional. The name of the area.</param>
|
||||
/// <param name="sortName">Optional. The sort name of the area.</param>
|
||||
/// <param name="disambiguation">Optional. The disambiguation comment of the area.</param>
|
||||
/// <param name="type">Optional. The MusicBrainz type of the area.</param>
|
||||
/// <param name="iso3166Code">Optional. The ISO 3166 code of the area.</param>
|
||||
/// <param name="includeMusicBrainzAreaId">Whether the MusicBrainz area Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeName">Whether the name should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeSortName">Whether the sort name should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeDisambiguation">Whether the disambiguation should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeType">Whether the type should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeIso3166Code">Whether the ISO 3166 code should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="MusicAreaDto"/> instance.</returns>
|
||||
public MusicAreaDto Create(
|
||||
Guid? musicBrainzAreaId = null,
|
||||
string? name = null,
|
||||
string? sortName = null,
|
||||
string? disambiguation = null,
|
||||
string? type = null,
|
||||
string? iso3166Code = null,
|
||||
bool includeMusicBrainzAreaId = true,
|
||||
bool includeName = true,
|
||||
bool includeSortName = true,
|
||||
bool includeDisambiguation = true,
|
||||
bool includeType = true,
|
||||
bool includeIso3166Code = true)
|
||||
{
|
||||
return new MusicAreaDto
|
||||
{
|
||||
MusicBrainzAreaId = includeMusicBrainzAreaId ? (musicBrainzAreaId ?? _faker.Random.Guid()) : null,
|
||||
Name = includeName ? (name ?? _faker.Address.Country()) : null,
|
||||
SortName = includeSortName ? (sortName ?? _faker.Address.Country()) : null,
|
||||
Disambiguation = includeDisambiguation ? (disambiguation ?? _faker.Lorem.Word()) : null,
|
||||
Type = includeType ? (type ?? _faker.Lorem.Word()) : null,
|
||||
Iso3166Code = includeIso3166Code ? (iso3166Code ?? _faker.Address.CountryCode()) : null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MusicAreaDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MusicAreaDto"/> instances.</returns>
|
||||
public List<MusicAreaDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MusicArtistAliasDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MusicArtistAliasDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="MusicArtistAliasDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="name">Optional. The name of the alias.</param>
|
||||
/// <param name="sortName">Optional. The sort name of the alias.</param>
|
||||
/// <param name="type">Optional. The type of the alias.</param>
|
||||
/// <param name="locale">Optional. The locale the alias is used in.</param>
|
||||
/// <param name="isPrimary">Optional. Whether this is the primary alias of the artist.</param>
|
||||
/// <param name="beginDate">Optional. The date the alias began being used.</param>
|
||||
/// <param name="endDate">Optional. The date the alias stopped being used.</param>
|
||||
/// <param name="isEnded">Optional. Whether the alias is no longer used.</param>
|
||||
/// <param name="includeName">Whether the name should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeSortName">Whether the sort name should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeType">Whether the type should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeLocale">Whether the locale should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeBeginDate">Whether the begin date should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeEndDate">Whether the end date should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="MusicArtistAliasDto"/> instance.</returns>
|
||||
public MusicArtistAliasDto Create(
|
||||
string? name = null,
|
||||
string? sortName = null,
|
||||
string? type = null,
|
||||
string? locale = null,
|
||||
bool isPrimary = false,
|
||||
DateOnly? beginDate = null,
|
||||
DateOnly? endDate = null,
|
||||
bool isEnded = false,
|
||||
bool includeName = true,
|
||||
bool includeSortName = true,
|
||||
bool includeType = true,
|
||||
bool includeLocale = true,
|
||||
bool includeBeginDate = true,
|
||||
bool includeEndDate = true)
|
||||
{
|
||||
DateOnly resolvedBeginDate = beginDate ?? DateOnly.FromDateTime(_faker.Date.Past());
|
||||
DateOnly resolvedEndDate = endDate ?? DateOnly.FromDateTime(_faker.Date.Future());
|
||||
|
||||
return new MusicArtistAliasDto
|
||||
{
|
||||
Name = includeName ? (name ?? _faker.Name.FullName()) : null,
|
||||
SortName = includeSortName ? (sortName ?? _faker.Name.LastName()) : null,
|
||||
Type = includeType ? (type ?? _faker.Lorem.Word()) : null,
|
||||
Locale = includeLocale ? (locale ?? _faker.Random.String2(2, "abcdefghijklmnopqrstuvwxyz")) : null,
|
||||
IsPrimary = isPrimary,
|
||||
BeginDate = includeBeginDate ? resolvedBeginDate : null,
|
||||
EndDate = includeEndDate ? resolvedEndDate : null,
|
||||
IsEnded = isEnded
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MusicArtistAliasDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MusicArtistAliasDto"/> instances.</returns>
|
||||
public List<MusicArtistAliasDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary;
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Presentation.Web.Common.DTO.MediaContributors;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.MediaContributors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MusicArtistDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MusicArtistDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly MusicArtistMetadataDtoFixture _musicArtistMetadataDtoFixture = new();
|
||||
private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new();
|
||||
private readonly AudioRatingDtoFixture _audioRatingDtoFixture = new();
|
||||
private readonly MusicAlbumDtoFixture _musicAlbumDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="MusicArtistDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the artist.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library this artist belongs to.</param>
|
||||
/// <param name="coverPath">Optional. The path of the image representing the artist.</param>
|
||||
/// <param name="metadata">Optional. The metadata of the artist.</param>
|
||||
/// <param name="website">Optional. The website of the artist.</param>
|
||||
/// <param name="musicBrainzArtistId">Optional. The MusicBrainz identifier of the artist.</param>
|
||||
/// <param name="ipis">Optional. The IPI codes of the artist.</param>
|
||||
/// <param name="isnis">Optional. The ISNI codes of the artist.</param>
|
||||
/// <param name="createdOnUtc">Optional. The date and time when the artist was created.</param>
|
||||
/// <param name="updatedOnUtc">Optional. The date and time when the artist was updated.</param>
|
||||
/// <param name="contributors">Optional. The references to the media contributors that make up the artist.</param>
|
||||
/// <param name="ratings">Optional. The ratings of the artist.</param>
|
||||
/// <param name="albums">Optional. The albums of the artist.</param>
|
||||
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeMetadata">Whether the metadata should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeWebsite">Whether the website should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeMusicBrainzArtistId">Whether the MusicBrainz artist Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeIpis">Whether the IPI codes should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeIsnis">Whether the ISNI codes should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the update date should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeContributors">Whether the contributors should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeRatings">Whether the ratings should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeAlbums">Whether the albums should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="MusicArtistDto"/> instance.</returns>
|
||||
public MusicArtistDto Create(
|
||||
Guid? id = null,
|
||||
Guid? libraryId = null,
|
||||
string? coverPath = null,
|
||||
MusicArtistMetadataDto? metadata = null,
|
||||
string? website = null,
|
||||
Guid? musicBrainzArtistId = null,
|
||||
List<string>? ipis = null,
|
||||
List<string>? isnis = null,
|
||||
DateTime? createdOnUtc = null,
|
||||
DateTime? updatedOnUtc = null,
|
||||
List<MediaContributorReferenceDto>? contributors = null,
|
||||
List<AudioRatingDto>? ratings = null,
|
||||
List<MusicAlbumDto>? albums = null,
|
||||
bool includeCoverPath = true,
|
||||
bool includeMetadata = true,
|
||||
bool includeWebsite = true,
|
||||
bool includeMusicBrainzArtistId = true,
|
||||
bool includeIpis = true,
|
||||
bool includeIsnis = true,
|
||||
bool includeUpdatedOnUtc = true,
|
||||
bool includeContributors = true,
|
||||
bool includeRatings = true,
|
||||
bool includeAlbums = true)
|
||||
{
|
||||
return new MusicArtistDto
|
||||
{
|
||||
Id = id ?? _faker.Random.Guid(),
|
||||
LibraryId = libraryId ?? _faker.Random.Guid(),
|
||||
CoverPath = includeCoverPath ? (coverPath ?? _faker.System.FilePath()) : null,
|
||||
Metadata = includeMetadata ? (metadata ?? _musicArtistMetadataDtoFixture.Create()) : null,
|
||||
Website = includeWebsite ? (website ?? _faker.Internet.Url()) : null,
|
||||
MusicBrainzArtistId = includeMusicBrainzArtistId ? (musicBrainzArtistId ?? _faker.Random.Guid()) : null,
|
||||
Ipis = includeIpis ? (ipis ?? [.. Enumerable.Range(0, _faker.Random.Number(1, 3)).Select(_ => _faker.Random.String2(10, "0123456789"))]) : null,
|
||||
Isnis = includeIsnis ? (isnis ?? [.. Enumerable.Range(0, _faker.Random.Number(1, 3)).Select(_ => _faker.Random.String2(16, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"))]) : null,
|
||||
CreatedOnUtc = createdOnUtc ?? _faker.Date.Past(),
|
||||
UpdatedOnUtc = includeUpdatedOnUtc ? (updatedOnUtc ?? _faker.Date.Recent()) : null,
|
||||
Contributors = includeContributors ? (contributors ?? [.. _mediaContributorReferenceDtoFixture.CreateMany(_faker.Random.Number(1, 3))]) : null,
|
||||
Ratings = includeRatings ? (ratings ?? [.. _audioRatingDtoFixture.CreateMany(_faker.Random.Number(1, 3))]) : null,
|
||||
Albums = includeAlbums ? (albums ?? [.. _musicAlbumDtoFixture.CreateMany(_faker.Random.Number(1, 3))]) : null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MusicArtistDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MusicArtistDto"/> instances.</returns>
|
||||
public List<MusicArtistDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MusicArtistLiteDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MusicArtistLiteDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="MusicArtistLiteDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the artist.</param>
|
||||
/// <param name="name">Optional. The name of the artist.</param>
|
||||
/// <param name="coverPath">Optional. The path of the image representing the artist.</param>
|
||||
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="MusicArtistLiteDto"/> instance.</returns>
|
||||
public MusicArtistLiteDto Create(
|
||||
Guid? id = null,
|
||||
string? name = null,
|
||||
string? coverPath = null,
|
||||
bool includeCoverPath = true)
|
||||
{
|
||||
return new MusicArtistLiteDto
|
||||
{
|
||||
Id = id ?? _faker.Random.Guid(),
|
||||
Name = name ?? _faker.Name.FullName(),
|
||||
CoverPath = includeCoverPath ? (coverPath ?? _faker.System.FilePath()) : null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MusicArtistLiteDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MusicArtistLiteDto"/> instances.</returns>
|
||||
public List<MusicArtistLiteDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.Enums.AudioLibrary;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MusicArtistMetadataDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MusicArtistMetadataDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly MusicAreaDtoFixture _musicAreaDtoFixture = new();
|
||||
private readonly MusicArtistAliasDtoFixture _musicArtistAliasDtoFixture = new();
|
||||
private readonly TagDtoFixture _tagDtoFixture = new();
|
||||
private readonly GenreDtoFixture _genreDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="MusicArtistMetadataDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="name">Optional. The name of the artist.</param>
|
||||
/// <param name="sortName">Optional. The sort name of the artist.</param>
|
||||
/// <param name="disambiguation">Optional. The disambiguation comment of the artist.</param>
|
||||
/// <param name="type">Optional. The type of the artist.</param>
|
||||
/// <param name="gender">Optional. The gender of the artist.</param>
|
||||
/// <param name="country">Optional. The ISO 3166-1 alpha-2 code of the country the artist is associated with.</param>
|
||||
/// <param name="area">Optional. The area the artist is primarily identified with.</param>
|
||||
/// <param name="beginArea">Optional. The area the artist began in.</param>
|
||||
/// <param name="endArea">Optional. The area the artist ended in.</param>
|
||||
/// <param name="lifeSpanBegin">Optional. The date the artist started existing.</param>
|
||||
/// <param name="lifeSpanEnd">Optional. The date the artist stopped existing.</param>
|
||||
/// <param name="isEnded">Optional. Whether the artist no longer exists.</param>
|
||||
/// <param name="genres">Optional. The genres associated with the artist.</param>
|
||||
/// <param name="tags">Optional. The tags that describe or categorize the artist.</param>
|
||||
/// <param name="aliases">Optional. The alternative names of the artist.</param>
|
||||
/// <param name="includeName">Whether the name should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeSortName">Whether the sort name should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeDisambiguation">Whether the disambiguation should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeType">Whether the type should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeGender">Whether the gender should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeCountry">Whether the country should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeArea">Whether the area should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeBeginArea">Whether the begin area should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeEndArea">Whether the end area should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeLifeSpanBegin">Whether the life span begin date should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeLifeSpanEnd">Whether the life span end date should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeGenres">Whether the genres should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeTags">Whether the tags should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeAliases">Whether the aliases should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="MusicArtistMetadataDto"/> instance.</returns>
|
||||
public MusicArtistMetadataDto Create(
|
||||
string? name = null,
|
||||
string? sortName = null,
|
||||
string? disambiguation = null,
|
||||
MusicArtistType? type = null,
|
||||
MusicArtistGender? gender = null,
|
||||
string? country = null,
|
||||
MusicAreaDto? area = null,
|
||||
MusicAreaDto? beginArea = null,
|
||||
MusicAreaDto? endArea = null,
|
||||
DateOnly? lifeSpanBegin = null,
|
||||
DateOnly? lifeSpanEnd = null,
|
||||
bool isEnded = false,
|
||||
List<GenreDto>? genres = null,
|
||||
List<TagDto>? tags = null,
|
||||
List<MusicArtistAliasDto>? aliases = null,
|
||||
bool includeName = true,
|
||||
bool includeSortName = true,
|
||||
bool includeDisambiguation = true,
|
||||
bool includeType = true,
|
||||
bool includeGender = true,
|
||||
bool includeCountry = true,
|
||||
bool includeArea = true,
|
||||
bool includeBeginArea = true,
|
||||
bool includeEndArea = true,
|
||||
bool includeLifeSpanBegin = true,
|
||||
bool includeLifeSpanEnd = true,
|
||||
bool includeGenres = true,
|
||||
bool includeTags = true,
|
||||
bool includeAliases = true)
|
||||
{
|
||||
return new MusicArtistMetadataDto
|
||||
{
|
||||
Name = includeName ? (name ?? _faker.Name.FullName()) : null,
|
||||
SortName = includeSortName ? (sortName ?? _faker.Name.LastName()) : null,
|
||||
Disambiguation = includeDisambiguation ? (disambiguation ?? _faker.Lorem.Word()) : null,
|
||||
Type = includeType ? (type ?? _faker.PickRandom<MusicArtistType>()) : null,
|
||||
Gender = includeGender ? (gender ?? _faker.PickRandom<MusicArtistGender>()) : null,
|
||||
Country = includeCountry ? (country ?? _faker.Address.CountryCode()) : null,
|
||||
Area = includeArea ? (area ?? _musicAreaDtoFixture.Create()) : null,
|
||||
BeginArea = includeBeginArea ? (beginArea ?? _musicAreaDtoFixture.Create()) : null,
|
||||
EndArea = includeEndArea ? (endArea ?? _musicAreaDtoFixture.Create()) : null,
|
||||
LifeSpanBegin = includeLifeSpanBegin ? (lifeSpanBegin ?? DateOnly.FromDateTime(_faker.Date.Past())) : null,
|
||||
LifeSpanEnd = includeLifeSpanEnd ? (lifeSpanEnd ?? DateOnly.FromDateTime(_faker.Date.Past())) : null,
|
||||
IsEnded = isEnded,
|
||||
Genres = includeGenres ? (genres ?? [.. _genreDtoFixture.CreateMany(_faker.Random.Number(1, 3))]) : null,
|
||||
Tags = includeTags ? (tags ?? [.. _tagDtoFixture.CreateMany(_faker.Random.Number(1, 3))]) : null,
|
||||
Aliases = includeAliases ? (aliases ?? [.. _musicArtistAliasDtoFixture.CreateMany(_faker.Random.Number(1, 3))]) : null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MusicArtistMetadataDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MusicArtistMetadataDto"/> instances.</returns>
|
||||
public List<MusicArtistMetadataDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MusicShuffleTrackDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MusicShuffleTrackDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="MusicShuffleTrackDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="trackId">Optional. The Id of the track.</param>
|
||||
/// <param name="title">Optional. The title of the track.</param>
|
||||
/// <param name="durationInSeconds">Optional. The duration of the track in seconds.</param>
|
||||
/// <param name="albumId">Optional. The Id of the album the track belongs to.</param>
|
||||
/// <param name="albumTitle">Optional. The title of the album the track belongs to.</param>
|
||||
/// <param name="artistId">Optional. The Id of the artist the album belongs to.</param>
|
||||
/// <param name="coverPath">Optional. The path of the cover of the album.</param>
|
||||
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="MusicShuffleTrackDto"/> instance.</returns>
|
||||
public MusicShuffleTrackDto Create(
|
||||
Guid? trackId = null,
|
||||
string? title = null,
|
||||
int? durationInSeconds = null,
|
||||
Guid? albumId = null,
|
||||
string? albumTitle = null,
|
||||
Guid? artistId = null,
|
||||
string? coverPath = null,
|
||||
bool includeCoverPath = true)
|
||||
{
|
||||
return new MusicShuffleTrackDto
|
||||
{
|
||||
TrackId = trackId ?? _faker.Random.Guid(),
|
||||
Title = title ?? _faker.Lorem.Sentence(),
|
||||
DurationInSeconds = durationInSeconds ?? _faker.Random.Int(1, 7200),
|
||||
AlbumId = albumId ?? _faker.Random.Guid(),
|
||||
AlbumTitle = albumTitle ?? _faker.Lorem.Sentence(),
|
||||
ArtistId = artistId ?? _faker.Random.Guid(),
|
||||
CoverPath = includeCoverPath ? (coverPath ?? _faker.System.FileName("jpg")) : null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MusicShuffleTrackDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MusicShuffleTrackDto"/> instances.</returns>
|
||||
public List<MusicShuffleTrackDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+136
@@ -0,0 +1,136 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary;
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.DTO.MediaContributors;
|
||||
using Lumina.Presentation.Web.Common.Enums.AudioLibrary;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.MediaContributors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MusicTrackDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MusicTrackDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly MusicTrackMetadataDtoFixture _musicTrackMetadataDtoFixture = new();
|
||||
private readonly MusicWorkDtoFixture _musicWorkDtoFixture = new();
|
||||
private readonly MoodDtoFixture _moodDtoFixture = new();
|
||||
private readonly IsrcDtoFixture _isrcDtoFixture = new();
|
||||
private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new();
|
||||
private readonly AudioRatingDtoFixture _audioRatingDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="MusicTrackDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the track.</param>
|
||||
/// <param name="albumId">Optional. The Id of the album the track belongs to.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library this track belongs to.</param>
|
||||
/// <param name="path">Optional. The file system path of the track.</param>
|
||||
/// <param name="metadata">Optional. The audio metadata of the track.</param>
|
||||
/// <param name="trackNumber">Optional. The number of the track on its disc.</param>
|
||||
/// <param name="discNumber">Optional. The number of the disc the track belongs to.</param>
|
||||
/// <param name="script">Optional. The script used by the language of the track.</param>
|
||||
/// <param name="key">Optional. The musical key of the track.</param>
|
||||
/// <param name="bpm">Optional. The tempo of the track in beats per minute.</param>
|
||||
/// <param name="work">Optional. The work the track is a recording of.</param>
|
||||
/// <param name="musicBrainzRecordingId">Optional. The MusicBrainz identifier of the recording.</param>
|
||||
/// <param name="musicBrainzTrackId">Optional. The MusicBrainz identifier of the track.</param>
|
||||
/// <param name="createdOnUtc">Optional. The date and time when the track was created.</param>
|
||||
/// <param name="updatedOnUtc">Optional. The date and time when the track was updated.</param>
|
||||
/// <param name="moods">Optional. The moods of the track.</param>
|
||||
/// <param name="isrcs">Optional. The ISRC codes of the track.</param>
|
||||
/// <param name="contributors">Optional. The references to the media contributors that performed on the track.</param>
|
||||
/// <param name="ratings">Optional. The ratings of the track.</param>
|
||||
/// <param name="includeMetadata">Whether the metadata should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeDiscNumber">Whether the disc number should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeScript">Whether the script should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeKey">Whether the musical key should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeBpm">Whether the tempo should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeWork">Whether the work should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeMusicBrainzRecordingId">Whether the MusicBrainz recording Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeMusicBrainzTrackId">Whether the MusicBrainz track Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the update date should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeMoods">Whether the moods should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeIsrcs">Whether the ISRC codes should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeContributors">Whether the contributors should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeRatings">Whether the ratings should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="MusicTrackDto"/> instance.</returns>
|
||||
public MusicTrackDto Create(
|
||||
Guid? id = null,
|
||||
Guid? albumId = null,
|
||||
Guid? libraryId = null,
|
||||
string? path = null,
|
||||
MusicTrackMetadataDto? metadata = null,
|
||||
int? trackNumber = null,
|
||||
int? discNumber = null,
|
||||
string? script = null,
|
||||
MusicKey? key = null,
|
||||
int? bpm = null,
|
||||
MusicWorkDto? work = null,
|
||||
Guid? musicBrainzRecordingId = null,
|
||||
Guid? musicBrainzTrackId = null,
|
||||
DateTime? createdOnUtc = null,
|
||||
DateTime? updatedOnUtc = null,
|
||||
List<MoodDto>? moods = null,
|
||||
List<IsrcDto>? isrcs = null,
|
||||
List<MediaContributorReferenceDto>? contributors = null,
|
||||
List<AudioRatingDto>? ratings = null,
|
||||
bool includeMetadata = true,
|
||||
bool includeDiscNumber = true,
|
||||
bool includeScript = true,
|
||||
bool includeKey = true,
|
||||
bool includeBpm = true,
|
||||
bool includeWork = true,
|
||||
bool includeMusicBrainzRecordingId = true,
|
||||
bool includeMusicBrainzTrackId = true,
|
||||
bool includeUpdatedOnUtc = true,
|
||||
bool includeMoods = true,
|
||||
bool includeIsrcs = true,
|
||||
bool includeContributors = true,
|
||||
bool includeRatings = true)
|
||||
{
|
||||
return new MusicTrackDto
|
||||
{
|
||||
Id = id ?? _faker.Random.Guid(),
|
||||
AlbumId = albumId ?? _faker.Random.Guid(),
|
||||
LibraryId = libraryId ?? _faker.Random.Guid(),
|
||||
Path = path ?? _faker.System.FilePath(),
|
||||
Metadata = includeMetadata ? (metadata ?? _musicTrackMetadataDtoFixture.Create()) : null,
|
||||
TrackNumber = trackNumber ?? _faker.Random.Number(1, 30),
|
||||
DiscNumber = includeDiscNumber ? (discNumber ?? _faker.Random.Number(1, 3)) : null,
|
||||
Script = includeScript ? (script ?? _faker.Lorem.Word()) : null,
|
||||
Key = includeKey ? (key ?? _faker.PickRandom<MusicKey>()) : null,
|
||||
Bpm = includeBpm ? (bpm ?? _faker.Random.Number(60, 200)) : null,
|
||||
Work = includeWork ? (work ?? _musicWorkDtoFixture.Create()) : null,
|
||||
MusicBrainzRecordingId = includeMusicBrainzRecordingId ? (musicBrainzRecordingId ?? _faker.Random.Guid()) : null,
|
||||
MusicBrainzTrackId = includeMusicBrainzTrackId ? (musicBrainzTrackId ?? _faker.Random.Guid()) : null,
|
||||
CreatedOnUtc = createdOnUtc ?? _faker.Date.Past(),
|
||||
UpdatedOnUtc = includeUpdatedOnUtc ? (updatedOnUtc ?? _faker.Date.Recent()) : null,
|
||||
Moods = includeMoods ? (moods ?? [.. _moodDtoFixture.CreateMany(_faker.Random.Number(1, 3))]) : null,
|
||||
Isrcs = includeIsrcs ? (isrcs ?? [.. _isrcDtoFixture.CreateMany(_faker.Random.Number(1, 3))]) : null,
|
||||
Contributors = includeContributors ? (contributors ?? [.. _mediaContributorReferenceDtoFixture.CreateMany(_faker.Random.Number(1, 3))]) : null,
|
||||
Ratings = includeRatings ? (ratings ?? [.. _audioRatingDtoFixture.CreateMany(_faker.Random.Number(1, 3))]) : null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MusicTrackDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MusicTrackDto"/> instances.</returns>
|
||||
public List<MusicTrackDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MusicTrackLiteDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MusicTrackLiteDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="MusicTrackLiteDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the track.</param>
|
||||
/// <param name="title">Optional. The title of the track.</param>
|
||||
/// <param name="trackNumber">Optional. The number of the track on its disc.</param>
|
||||
/// <param name="discNumber">Optional. The number of the disc the track belongs to.</param>
|
||||
/// <param name="durationInSeconds">Optional. The duration of the track in seconds.</param>
|
||||
/// <param name="includeDiscNumber">Whether the disc number should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="MusicTrackLiteDto"/> instance.</returns>
|
||||
public MusicTrackLiteDto Create(
|
||||
Guid? id = null,
|
||||
string? title = null,
|
||||
int? trackNumber = null,
|
||||
int? discNumber = null,
|
||||
int? durationInSeconds = null,
|
||||
bool includeDiscNumber = true)
|
||||
{
|
||||
return new MusicTrackLiteDto
|
||||
{
|
||||
Id = id ?? _faker.Random.Guid(),
|
||||
Title = title ?? _faker.Lorem.Sentence(3),
|
||||
TrackNumber = trackNumber ?? _faker.Random.Number(1, 30),
|
||||
DiscNumber = includeDiscNumber ? (discNumber ?? _faker.Random.Number(1, 3)) : null,
|
||||
DurationInSeconds = durationInSeconds ?? _faker.Random.Number(30, 600)
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MusicTrackLiteDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MusicTrackLiteDto"/> instances.</returns>
|
||||
public List<MusicTrackLiteDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+148
@@ -0,0 +1,148 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.Common;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MusicTrackMetadataDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MusicTrackMetadataDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly ReleaseInfoDtoFixture _releaseInfoDtoFixture = new();
|
||||
private readonly LanguageInfoDtoFixture _languageInfoDtoFixture = new();
|
||||
private readonly TagDtoFixture _tagDtoFixture = new();
|
||||
private readonly GenreDtoFixture _genreDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="MusicTrackMetadataDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="title">Optional. The title of the track.</param>
|
||||
/// <param name="originalTitle">Optional. The original title of the track.</param>
|
||||
/// <param name="description">Optional. A brief description of the track.</param>
|
||||
/// <param name="disambiguation">Optional. The disambiguation comment of the track.</param>
|
||||
/// <param name="releaseInfo">Optional. The release information of the track.</param>
|
||||
/// <param name="language">Optional. The language of the track.</param>
|
||||
/// <param name="originalLanguage">Optional. The original language of the track.</param>
|
||||
/// <param name="tags">Optional. The tags that describe or categorize the track.</param>
|
||||
/// <param name="genres">Optional. The genres associated with the track.</param>
|
||||
/// <param name="isVideo">Optional. Whether the recording of the track is a video recording.</param>
|
||||
/// <param name="durationInSeconds">Optional. The duration of the audio of the track in seconds.</param>
|
||||
/// <param name="sampleRate">Optional. The sample rate of the audio of the track in Hz.</param>
|
||||
/// <param name="channels">Optional. The number of audio channels of the track.</param>
|
||||
/// <param name="bitDepth">Optional. The bit depth of the audio of the track.</param>
|
||||
/// <param name="audioCodec">Optional. The audio codec used by the track.</param>
|
||||
/// <param name="bitrate">Optional. The bitrate of the audio of the track in kbps.</param>
|
||||
/// <param name="acoustId">Optional. The AcoustID fingerprint identifier of the audio file of the track.</param>
|
||||
/// <param name="replayGainTrackGain">Optional. The ReplayGain track gain of the track in decibels.</param>
|
||||
/// <param name="replayGainTrackPeak">Optional. The ReplayGain track peak of the track.</param>
|
||||
/// <param name="replayGainAlbumGain">Optional. The ReplayGain album gain of the track in decibels.</param>
|
||||
/// <param name="replayGainAlbumPeak">Optional. The ReplayGain album peak of the track.</param>
|
||||
/// <param name="includeTitle">Whether the title should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeOriginalTitle">Whether the original title should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeDescription">Whether the description should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeDisambiguation">Whether the disambiguation should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeReleaseInfo">Whether the release information should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeLanguage">Whether the language should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeOriginalLanguage">Whether the original language should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeTags">Whether the tags should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeGenres">Whether the genres should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeDurationInSeconds">Whether the duration should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeSampleRate">Whether the sample rate should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeChannels">Whether the channels should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeBitDepth">Whether the bit depth should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeAudioCodec">Whether the audio codec should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeBitrate">Whether the bitrate should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeAcoustId">Whether the AcoustID should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeReplayGainTrackGain">Whether the ReplayGain track gain should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeReplayGainTrackPeak">Whether the ReplayGain track peak should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeReplayGainAlbumGain">Whether the ReplayGain album gain should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeReplayGainAlbumPeak">Whether the ReplayGain album peak should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="MusicTrackMetadataDto"/> instance.</returns>
|
||||
public MusicTrackMetadataDto Create(
|
||||
string? title = null,
|
||||
string? originalTitle = null,
|
||||
string? description = null,
|
||||
string? disambiguation = null,
|
||||
ReleaseInfoDto? releaseInfo = null,
|
||||
LanguageInfoDto? language = null,
|
||||
LanguageInfoDto? originalLanguage = null,
|
||||
List<TagDto>? tags = null,
|
||||
List<GenreDto>? genres = null,
|
||||
bool isVideo = false,
|
||||
int? durationInSeconds = null,
|
||||
int? sampleRate = null,
|
||||
int? channels = null,
|
||||
int? bitDepth = null,
|
||||
string? audioCodec = null,
|
||||
int? bitrate = null,
|
||||
string? acoustId = null,
|
||||
decimal? replayGainTrackGain = null,
|
||||
decimal? replayGainTrackPeak = null,
|
||||
decimal? replayGainAlbumGain = null,
|
||||
decimal? replayGainAlbumPeak = null,
|
||||
bool includeTitle = true,
|
||||
bool includeOriginalTitle = true,
|
||||
bool includeDescription = true,
|
||||
bool includeDisambiguation = true,
|
||||
bool includeReleaseInfo = true,
|
||||
bool includeLanguage = true,
|
||||
bool includeOriginalLanguage = true,
|
||||
bool includeTags = true,
|
||||
bool includeGenres = true,
|
||||
bool includeDurationInSeconds = true,
|
||||
bool includeSampleRate = true,
|
||||
bool includeChannels = true,
|
||||
bool includeBitDepth = true,
|
||||
bool includeAudioCodec = true,
|
||||
bool includeBitrate = true,
|
||||
bool includeAcoustId = true,
|
||||
bool includeReplayGainTrackGain = true,
|
||||
bool includeReplayGainTrackPeak = true,
|
||||
bool includeReplayGainAlbumGain = true,
|
||||
bool includeReplayGainAlbumPeak = true)
|
||||
{
|
||||
return new MusicTrackMetadataDto
|
||||
{
|
||||
Title = includeTitle ? (title ?? _faker.Lorem.Sentence(3)) : null,
|
||||
OriginalTitle = includeOriginalTitle ? (originalTitle ?? _faker.Lorem.Sentence(3)) : null,
|
||||
Description = includeDescription ? (description ?? _faker.Lorem.Paragraph()) : null,
|
||||
Disambiguation = includeDisambiguation ? (disambiguation ?? _faker.Lorem.Word()) : null,
|
||||
ReleaseInfo = includeReleaseInfo ? (releaseInfo ?? _releaseInfoDtoFixture.Create()) : null,
|
||||
Language = includeLanguage ? (language ?? _languageInfoDtoFixture.Create()) : null,
|
||||
OriginalLanguage = includeOriginalLanguage ? (originalLanguage ?? _languageInfoDtoFixture.Create()) : null,
|
||||
Tags = includeTags ? (tags ?? [.. _tagDtoFixture.CreateMany(_faker.Random.Number(1, 3))]) : null,
|
||||
Genres = includeGenres ? (genres ?? [.. _genreDtoFixture.CreateMany(_faker.Random.Number(1, 3))]) : null,
|
||||
IsVideo = isVideo,
|
||||
DurationInSeconds = includeDurationInSeconds ? (durationInSeconds ?? _faker.Random.Number(30, 600)) : null,
|
||||
SampleRate = includeSampleRate ? (sampleRate ?? _faker.Random.Number(22050, 192000)) : null,
|
||||
Channels = includeChannels ? (channels ?? _faker.Random.Number(1, 8)) : null,
|
||||
BitDepth = includeBitDepth ? (bitDepth ?? _faker.Random.Number(8, 32)) : null,
|
||||
AudioCodec = includeAudioCodec ? (audioCodec ?? _faker.Lorem.Word()) : null,
|
||||
Bitrate = includeBitrate ? (bitrate ?? _faker.Random.Number(64, 1411)) : null,
|
||||
AcoustId = includeAcoustId ? (acoustId ?? _faker.Random.String2(32, "0123456789abcdef")) : null,
|
||||
ReplayGainTrackGain = includeReplayGainTrackGain ? (replayGainTrackGain ?? _faker.Random.Decimal(-20m, 0m)) : null,
|
||||
ReplayGainTrackPeak = includeReplayGainTrackPeak ? (replayGainTrackPeak ?? _faker.Random.Decimal(0m, 1m)) : null,
|
||||
ReplayGainAlbumGain = includeReplayGainAlbumGain ? (replayGainAlbumGain ?? _faker.Random.Decimal(-20m, 0m)) : null,
|
||||
ReplayGainAlbumPeak = includeReplayGainAlbumPeak ? (replayGainAlbumPeak ?? _faker.Random.Decimal(0m, 1m)) : null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MusicTrackMetadataDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MusicTrackMetadataDto"/> instances.</returns>
|
||||
public List<MusicTrackMetadataDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MusicWorkDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MusicWorkDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly LanguageInfoDtoFixture _languageInfoDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="MusicWorkDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="musicBrainzWorkId">Optional. The MusicBrainz identifier of the work.</param>
|
||||
/// <param name="title">Optional. The title of the work.</param>
|
||||
/// <param name="type">Optional. The MusicBrainz type of the work.</param>
|
||||
/// <param name="languages">Optional. The languages of the work.</param>
|
||||
/// <param name="iswcs">Optional. The ISWC codes of the work.</param>
|
||||
/// <param name="includeMusicBrainzWorkId">Whether the MusicBrainz work Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeTitle">Whether the title should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeType">Whether the type should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeLanguages">Whether the languages should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeIswcs">Whether the ISWC codes should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="MusicWorkDto"/> instance.</returns>
|
||||
public MusicWorkDto Create(
|
||||
Guid? musicBrainzWorkId = null,
|
||||
string? title = null,
|
||||
string? type = null,
|
||||
List<LanguageInfoDto>? languages = null,
|
||||
List<string>? iswcs = null,
|
||||
bool includeMusicBrainzWorkId = true,
|
||||
bool includeTitle = true,
|
||||
bool includeType = true,
|
||||
bool includeLanguages = true,
|
||||
bool includeIswcs = true)
|
||||
{
|
||||
return new MusicWorkDto
|
||||
{
|
||||
MusicBrainzWorkId = includeMusicBrainzWorkId ? (musicBrainzWorkId ?? _faker.Random.Guid()) : null,
|
||||
Title = includeTitle ? (title ?? _faker.Lorem.Sentence(3)) : null,
|
||||
Type = includeType ? (type ?? _faker.Lorem.Word()) : null,
|
||||
Languages = includeLanguages ? (languages ?? [.. _languageInfoDtoFixture.CreateMany(_faker.Random.Number(1, 3))]) : null,
|
||||
Iswcs = includeIswcs ? (iswcs ?? [.. Enumerable.Range(0, _faker.Random.Number(1, 3)).Select(_ => $"T{_faker.Random.Number(100000000, 999999999)}")]) : null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MusicWorkDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MusicWorkDto"/> instances.</returns>
|
||||
public List<MusicWorkDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Presentation.Web.Common.Enums.AudioLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaybackManifestDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaybackManifestDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="PlaybackManifestDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="trackId">Optional. The Id of the track the manifest describes.</param>
|
||||
/// <param name="durationInSeconds">Optional. The duration of the audio of the track, in seconds.</param>
|
||||
/// <param name="sourceContainer">Optional. The container of the stored audio file of the track.</param>
|
||||
/// <param name="sourceCodec">Optional. The codec of the stored audio of the track.</param>
|
||||
/// <param name="sampleRate">Optional. The sample rate of the stored audio, in Hz.</param>
|
||||
/// <param name="channels">Optional. The number of audio channels of the track.</param>
|
||||
/// <param name="bitDepth">Optional. The bit depth of the stored audio of the track.</param>
|
||||
/// <param name="replayGainTrackGain">Optional. The ReplayGain track gain of the track, in decibels.</param>
|
||||
/// <param name="replayGainTrackPeak">Optional. The ReplayGain track peak of the track.</param>
|
||||
/// <param name="replayGainAlbumGain">Optional. The ReplayGain album gain of the track, in decibels.</param>
|
||||
/// <param name="replayGainAlbumPeak">Optional. The ReplayGain album peak of the track.</param>
|
||||
/// <param name="isDirectPlay">Whether the stored audio is delivered as it is.</param>
|
||||
/// <param name="deliveryContainer">Optional. The container of the delivered audio.</param>
|
||||
/// <param name="deliveryCodec">Optional. The codec of the delivered audio.</param>
|
||||
/// <param name="deliveryShape">Optional. The shape the delivered audio is addressed by.</param>
|
||||
/// <param name="segmentDurationSeconds">Optional. The duration of each segment of the delivered audio, in seconds.</param>
|
||||
/// <param name="isSeekable">Whether the delivered audio can be seeked by the player.</param>
|
||||
/// <param name="streamPath">Optional. The relative path of the track stream.</param>
|
||||
/// <param name="deliveryId">Optional. The opaque handle of the normalized delivery.</param>
|
||||
/// <param name="segmentStreamPathTemplate">Optional. The relative path template of the segment route.</param>
|
||||
/// <param name="includeBitDepth">Whether the bit depth should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeReplayGain">Whether the ReplayGain values should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeDeliveryContainer">Whether the delivery container should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeDeliveryCodec">Whether the delivery codec should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeDeliveryShape">Whether the delivery shape should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeSegmentDurationSeconds">Whether the segment duration should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeDeliveryId">Whether the delivery handle should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeSegmentStreamPathTemplate">Whether the segment path template should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="PlaybackManifestDto"/> instance.</returns>
|
||||
public PlaybackManifestDto Create(
|
||||
Guid? trackId = null,
|
||||
int? durationInSeconds = null,
|
||||
string? sourceContainer = null,
|
||||
string? sourceCodec = null,
|
||||
int? sampleRate = null,
|
||||
int? channels = null,
|
||||
int? bitDepth = null,
|
||||
decimal? replayGainTrackGain = null,
|
||||
decimal? replayGainTrackPeak = null,
|
||||
decimal? replayGainAlbumGain = null,
|
||||
decimal? replayGainAlbumPeak = null,
|
||||
bool isDirectPlay = false,
|
||||
string? deliveryContainer = null,
|
||||
string? deliveryCodec = null,
|
||||
PlaybackDeliveryShape? deliveryShape = null,
|
||||
int? segmentDurationSeconds = null,
|
||||
bool isSeekable = true,
|
||||
string? streamPath = null,
|
||||
string? deliveryId = null,
|
||||
string? segmentStreamPathTemplate = null,
|
||||
bool includeBitDepth = true,
|
||||
bool includeReplayGain = true,
|
||||
bool includeDeliveryContainer = true,
|
||||
bool includeDeliveryCodec = true,
|
||||
bool includeDeliveryShape = true,
|
||||
bool includeSegmentDurationSeconds = true,
|
||||
bool includeDeliveryId = true,
|
||||
bool includeSegmentStreamPathTemplate = true)
|
||||
{
|
||||
Guid resolvedTrackId = trackId ?? _faker.Random.Guid();
|
||||
return new PlaybackManifestDto
|
||||
{
|
||||
TrackId = resolvedTrackId,
|
||||
DurationInSeconds = durationInSeconds ?? _faker.Random.Int(1, 3600),
|
||||
SourceContainer = sourceContainer ?? _faker.PickRandom("FLAC", "MP3", "OGG", "MP4", "AAC", "WAV"),
|
||||
SourceCodec = sourceCodec ?? _faker.PickRandom("FLAC", "MP3", "AAC", "ALAC", "OPUS", "PCM"),
|
||||
SampleRate = sampleRate ?? _faker.PickRandom(44100, 48000, 96000),
|
||||
Channels = channels ?? _faker.PickRandom(1, 2, 6),
|
||||
BitDepth = includeBitDepth ? (bitDepth ?? _faker.Random.Int(8, 32)) : null,
|
||||
ReplayGainTrackGain = includeReplayGain ? (replayGainTrackGain ?? _faker.Random.Decimal(-20m, 0m)) : null,
|
||||
ReplayGainTrackPeak = includeReplayGain ? (replayGainTrackPeak ?? _faker.Random.Decimal(0m, 1.5m)) : null,
|
||||
ReplayGainAlbumGain = includeReplayGain ? (replayGainAlbumGain ?? _faker.Random.Decimal(-20m, 0m)) : null,
|
||||
ReplayGainAlbumPeak = includeReplayGain ? (replayGainAlbumPeak ?? _faker.Random.Decimal(0m, 1.5m)) : null,
|
||||
IsDirectPlay = isDirectPlay,
|
||||
DeliveryContainer = includeDeliveryContainer ? (deliveryContainer ?? "MP3") : null,
|
||||
DeliveryCodec = includeDeliveryCodec ? (deliveryCodec ?? "MP3") : null,
|
||||
DeliveryShape = includeDeliveryShape ? (deliveryShape ?? PlaybackDeliveryShape.TimeAddressedSegments) : null,
|
||||
SegmentDurationSeconds = includeSegmentDurationSeconds ? (segmentDurationSeconds ?? 6) : null,
|
||||
IsSeekable = isSeekable,
|
||||
StreamPath = streamPath ?? $"/libraries/{Guid.NewGuid():N}/artists/{Guid.NewGuid():N}/albums/{Guid.NewGuid():N}/tracks/{resolvedTrackId:N}/stream",
|
||||
DeliveryId = includeDeliveryId ? (deliveryId ?? Guid.NewGuid().ToString("N")) : null,
|
||||
SegmentStreamPathTemplate = includeSegmentStreamPathTemplate
|
||||
? (segmentStreamPathTemplate ?? $"/libraries/{Guid.NewGuid():N}/artists/{Guid.NewGuid():N}/albums/{Guid.NewGuid():N}/tracks/{resolvedTrackId:N}/stream/deliveries/{{deliveryId}}/segments/{{segmentIndex}}")
|
||||
: null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="PlaybackManifestDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaybackManifestDto"/> instances.</returns>
|
||||
public List<PlaybackManifestDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="UpdateMusicCoverDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UpdateMusicCoverDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="UpdateMusicCoverDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="coverPath">Optional. The relative path of the stored cover image.</param>
|
||||
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="UpdateMusicCoverDto"/> instance.</returns>
|
||||
public UpdateMusicCoverDto Create(
|
||||
string? coverPath = null,
|
||||
bool includeCoverPath = true)
|
||||
{
|
||||
return new UpdateMusicCoverDto
|
||||
{
|
||||
CoverPath = includeCoverPath ? (coverPath ?? _faker.System.FilePath()) : null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="UpdateMusicCoverDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="UpdateMusicCoverDto"/> instances.</returns>
|
||||
public List<UpdateMusicCoverDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Authorization;
|
||||
using Lumina.Presentation.Web.Common.Enums.Authorization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Authorization;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PermissionDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PermissionDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="PermissionDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional unique identifier of the permission.</param>
|
||||
/// <param name="permission">Optional name of the permission.</param>
|
||||
/// <returns>A configured <see cref="PermissionDto"/> instance.</returns>
|
||||
public PermissionDto Create(
|
||||
Guid? id = null,
|
||||
AuthorizationPermission? permission = null)
|
||||
{
|
||||
return new PermissionDto(
|
||||
Id: id ?? Guid.NewGuid(),
|
||||
PermissionName: permission ?? _faker.Random.Enum<AuthorizationPermission>()
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="PermissionDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PermissionDto"/> instances.</returns>
|
||||
public List<PermissionDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Authorization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Authorization;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="RoleDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class RoleDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="RoleDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional identifier of the role.</param>
|
||||
/// <param name="roleName">Optional name of the role.</param>
|
||||
/// <returns>A configured <see cref="RoleDto"/> instance.</returns>
|
||||
public RoleDto Create(Guid? id = null, string? roleName = null)
|
||||
{
|
||||
return new RoleDto(
|
||||
Id: id ?? Guid.NewGuid(),
|
||||
RoleName: roleName ?? _faker.Commerce.Department()
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="RoleDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="RoleDto"/> instances.</returns>
|
||||
public List<RoleDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.DTO.Authorization;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Authorization;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="RolePermissionsDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class RolePermissionsDtoFixture
|
||||
{
|
||||
private readonly RoleDtoFixture _roleDtoFixture = new();
|
||||
private readonly PermissionDtoFixture _permissionDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="RolePermissionsDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="role">Optional. The authorization role.</param>
|
||||
/// <param name="permissions">Optional. The permissions of the authorization role.</param>
|
||||
/// <returns>The created <see cref="RolePermissionsDto"/>.</returns>
|
||||
public RolePermissionsDto Create(
|
||||
RoleDto? role = null,
|
||||
PermissionDto[]? permissions = null)
|
||||
{
|
||||
return new RolePermissionsDto(
|
||||
role ?? _roleDtoFixture.Create(),
|
||||
permissions ?? [.. _permissionDtoFixture.CreateMany()]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="RolePermissionsDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="RolePermissionsDto"/> instances.</returns>
|
||||
public List<RolePermissionsDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GenreDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GenreDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="GenreDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="name">Optional. The name of the genre.</param>
|
||||
/// <returns>A configured <see cref="GenreDto"/> instance.</returns>
|
||||
public GenreDto Create(string? name = null)
|
||||
{
|
||||
return new GenreDto
|
||||
{
|
||||
Name = name ?? _faker.Lorem.Word()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="GenreDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GenreDto"/> instances.</returns>
|
||||
public List<GenreDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LanguageInfoDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LanguageInfoDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="LanguageInfoDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="languageCode">Optional. The ISO 639-1 two-letter language code.</param>
|
||||
/// <param name="languageName">Optional. The name of the language in English.</param>
|
||||
/// <param name="nativeName">Optional. The native name of the language.</param>
|
||||
/// <returns>A configured <see cref="LanguageInfoDto"/> instance.</returns>
|
||||
public LanguageInfoDto Create(
|
||||
string? languageCode = null,
|
||||
string? languageName = null,
|
||||
string? nativeName = null)
|
||||
{
|
||||
return new LanguageInfoDto
|
||||
{
|
||||
LanguageCode = languageCode ?? _faker.Random.String2(2, "abcdefghijklmnopqrstuvwxyz"),
|
||||
LanguageName = languageName ?? _faker.Address.Country(),
|
||||
NativeName = nativeName ?? _faker.Lorem.Word()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="LanguageInfoDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="LanguageInfoDto"/> instances.</returns>
|
||||
public List<LanguageInfoDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.Enums.MediaLibrary;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaArtworkDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaArtworkDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="MediaArtworkDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="type">Optional. The type of the artwork.</param>
|
||||
/// <param name="ordinal">Optional. The ordinal of the artwork within its type.</param>
|
||||
/// <param name="path">Optional. The relative path of the stored artwork file.</param>
|
||||
/// <returns>A configured <see cref="MediaArtworkDto"/> instance.</returns>
|
||||
public MediaArtworkDto Create(
|
||||
ArtworkType? type = null,
|
||||
int? ordinal = null,
|
||||
string? path = null)
|
||||
{
|
||||
return new MediaArtworkDto
|
||||
{
|
||||
Type = type ?? _faker.PickRandom<ArtworkType>(),
|
||||
Ordinal = ordinal ?? _faker.Random.Int(1, 10),
|
||||
Path = path ?? _faker.System.FilePath()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MediaArtworkDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaArtworkDto"/> instances.</returns>
|
||||
public List<MediaArtworkDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MoodDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MoodDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="MoodDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="name">Optional. The name of the mood.</param>
|
||||
/// <param name="includeName">Whether the name should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="MoodDto"/> instance.</returns>
|
||||
public MoodDto Create(
|
||||
string? name = null,
|
||||
bool includeName = true)
|
||||
{
|
||||
return new MoodDto
|
||||
{
|
||||
Name = includeName ? (name ?? _faker.Lorem.Word()) : null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MoodDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MoodDto"/> instances.</returns>
|
||||
public List<MoodDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PaginatedDto{T}"/> class.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the elements of the page.</typeparam>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PaginatedDtoFixture<T>
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="PaginatedDto{T}"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="data">Optional collection of elements of the page.</param>
|
||||
/// <param name="currentPage">Optional current page number in a paginated collection.</param>
|
||||
/// <param name="perPage">Optional number of items to include per page in paginated results.</param>
|
||||
/// <param name="count">Optional total number of elements available in the paginated result set.</param>
|
||||
/// <param name="numberOfPages">Optional total number of pages based on the elements available and per page.</param>
|
||||
/// <returns>A configured <see cref="PaginatedDto{T}"/> instance.</returns>
|
||||
public PaginatedDto<T> Create(
|
||||
IReadOnlyList<T>? data = null,
|
||||
int? currentPage = null,
|
||||
int? perPage = null,
|
||||
int? count = null,
|
||||
int? numberOfPages = null)
|
||||
{
|
||||
return new PaginatedDto<T>(
|
||||
Data: data is null ? [] : [.. data],
|
||||
CurrentPage: currentPage ?? _faker.Random.Int(1, 10),
|
||||
PerPage: perPage ?? _faker.Random.Int(1, 100),
|
||||
Count: count ?? _faker.Random.Int(0, 1000),
|
||||
NumberOfPages: numberOfPages ?? _faker.Random.Int(1, 100));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="PaginatedDto{T}"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PaginatedDto{T}"/> instances.</returns>
|
||||
public List<PaginatedDto<T>> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ProblemDetailsDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ProblemDetailsDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ProblemDetailsDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="type">Optional. The URI reference that identifies the problem type.</param>
|
||||
/// <param name="title">Optional. A short, human-readable summary of the problem type.</param>
|
||||
/// <param name="status">Optional. The HTTP status code generated by the server.</param>
|
||||
/// <param name="detail">Optional. A detailed explanation specific to this occurrence of the problem.</param>
|
||||
/// <param name="instance">Optional. A URI reference that identifies the specific occurrence of the problem.</param>
|
||||
/// <param name="includeType">Whether the problem type should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeDetail">Whether the problem detail should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="ProblemDetailsDto"/>.</returns>
|
||||
public ProblemDetailsDto Create(
|
||||
string? type = null,
|
||||
string? title = null,
|
||||
int? status = null,
|
||||
string? detail = null,
|
||||
string? instance = null,
|
||||
bool includeType = true,
|
||||
bool includeDetail = true)
|
||||
{
|
||||
return new ProblemDetailsDto
|
||||
{
|
||||
Type = includeType ? (type ?? "https://tools.ietf.org/html/rfc4918#section-11.2") : null,
|
||||
Title = title ?? _faker.Lorem.Word(),
|
||||
Status = status ?? _faker.Random.Int(400, 599),
|
||||
Detail = includeDetail ? (detail ?? _faker.Lorem.Sentence()) : null,
|
||||
Instance = instance
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ProblemDetailsDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ProblemDetailsDto"/> instances.</returns>
|
||||
public List<ProblemDetailsDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.Enums.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ReleaseInfoDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReleaseInfoDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ReleaseInfoDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="originalReleaseDate">Optional. The original release date of the content.</param>
|
||||
/// <param name="originalReleaseYear">Optional. The original release year of the content.</param>
|
||||
/// <param name="reReleaseDate">Optional. The re-release date of the content.</param>
|
||||
/// <param name="reReleaseYear">Optional. The re-release year of the content.</param>
|
||||
/// <param name="releaseCountry">Optional. The country where the content was released.</param>
|
||||
/// <param name="releaseVersion">Optional. The version or edition of the content's release.</param>
|
||||
/// <returns>A configured <see cref="ReleaseInfoDto"/> instance.</returns>
|
||||
public ReleaseInfoDto Create(
|
||||
DateOnly? originalReleaseDate = null,
|
||||
int? originalReleaseYear = null,
|
||||
DateOnly? reReleaseDate = null,
|
||||
int? reReleaseYear = null,
|
||||
ReleaseCountry? releaseCountry = null,
|
||||
string? releaseVersion = null)
|
||||
{
|
||||
int resolvedOriginalReleaseYear = originalReleaseYear ?? (originalReleaseDate?.Year ?? Random.Shared.Next(1900, 2026));
|
||||
DateOnly resolvedOriginalReleaseDate = originalReleaseDate ?? new DateOnly(resolvedOriginalReleaseYear, 1, 1);
|
||||
int resolvedReReleaseYear = reReleaseYear ?? (reReleaseDate?.Year ?? Random.Shared.Next(resolvedOriginalReleaseYear, resolvedOriginalReleaseYear + 100));
|
||||
DateOnly resolvedReReleaseDate = reReleaseDate ?? new DateOnly(resolvedReReleaseYear, 1, 1);
|
||||
|
||||
return new ReleaseInfoDto
|
||||
{
|
||||
OriginalReleaseDate = resolvedOriginalReleaseDate,
|
||||
OriginalReleaseYear = resolvedOriginalReleaseYear,
|
||||
ReReleaseDate = resolvedReReleaseDate,
|
||||
ReReleaseYear = resolvedReReleaseYear,
|
||||
ReleaseCountry = releaseCountry ?? _faker.PickRandom<ReleaseCountry>(),
|
||||
ReleaseVersion = releaseVersion ?? _faker.Random.String2(_faker.Random.Number(1, 50))
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="ReleaseInfoDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ReleaseInfoDto"/> instances.</returns>
|
||||
public List<ReleaseInfoDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="TagDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class TagDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="TagDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="name">Optional. The name of the tag.</param>
|
||||
/// <returns>A configured <see cref="TagDto"/> instance.</returns>
|
||||
public TagDto Create(string? name = null)
|
||||
{
|
||||
return new TagDto
|
||||
{
|
||||
Name = name ?? _faker.Lorem.Word()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="TagDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="TagDto"/> instances.</returns>
|
||||
public List<TagDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Configuration;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Configuration;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="EncryptionSettingsDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class EncryptionSettingsDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="EncryptionSettingsDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="secretKey">Optional. The secret key used to encrypt data.</param>
|
||||
/// <returns>The created <see cref="EncryptionSettingsDto"/>.</returns>
|
||||
public EncryptionSettingsDto Create(
|
||||
string? secretKey = null)
|
||||
{
|
||||
return new EncryptionSettingsDto
|
||||
{
|
||||
SecretKey = secretKey ?? _faker.Random.String2(44, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=")
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="EncryptionSettingsDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="EncryptionSettingsDto"/> instances.</returns>
|
||||
public List<EncryptionSettingsDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Configuration;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Configuration;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ServerConfigurationDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ServerConfigurationDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ServerConfigurationDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="apiVersion">Optional. The remote API server path version.</param>
|
||||
/// <param name="baseAddress">Optional. The remote API server path.</param>
|
||||
/// <param name="port">Optional. The remote API server port.</param>
|
||||
/// <returns>The created <see cref="ServerConfigurationDto"/>.</returns>
|
||||
public ServerConfigurationDto Create(
|
||||
char? apiVersion = null,
|
||||
string? baseAddress = null,
|
||||
ushort? port = null)
|
||||
{
|
||||
return new ServerConfigurationDto
|
||||
{
|
||||
ApiVersion = apiVersion ?? _faker.Random.Char('1', '9'),
|
||||
BaseAddress = baseAddress ?? "http://localhost",
|
||||
Port = port ?? _faker.Random.UShort()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ServerConfigurationDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ServerConfigurationDto"/> instances.</returns>
|
||||
public List<ServerConfigurationDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Favorites;
|
||||
using Lumina.Presentation.Web.Common.Enums.Favorites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Favorites;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="FavoriteDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FavoriteDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly FavoriteMediaKind[] _supportedMediaKinds =
|
||||
[
|
||||
FavoriteMediaKind.MusicArtist,
|
||||
FavoriteMediaKind.MusicAlbum,
|
||||
FavoriteMediaKind.MusicTrack,
|
||||
FavoriteMediaKind.Book
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="FavoriteDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional Id of the favorite.</param>
|
||||
/// <param name="mediaKind">Optional kind of the favorited media item.</param>
|
||||
/// <param name="mediaItemId">Optional Id of the favorited media item.</param>
|
||||
/// <param name="favoritedOnUtc">Optional date and time when the media item was favorited.</param>
|
||||
/// <returns>A configured <see cref="FavoriteDto"/> instance.</returns>
|
||||
public FavoriteDto Create(
|
||||
Guid? id = null,
|
||||
FavoriteMediaKind? mediaKind = null,
|
||||
Guid? mediaItemId = null,
|
||||
DateTime? favoritedOnUtc = null)
|
||||
{
|
||||
return new FavoriteDto(
|
||||
Id: id ?? _faker.Random.Guid(),
|
||||
MediaKind: mediaKind ?? _faker.PickRandom(_supportedMediaKinds),
|
||||
MediaItemId: mediaItemId ?? _faker.Random.Guid(),
|
||||
FavoritedOnUtc: favoritedOnUtc ?? _faker.Date.Between(new DateTime(2024, 1, 1), new DateTime(2026, 12, 31))
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="FavoriteDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="FavoriteDto"/> instances.</returns>
|
||||
public List<FavoriteDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Favorites;
|
||||
using Lumina.Presentation.Web.Common.Enums.Favorites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Favorites;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="FavoriteItemDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FavoriteItemDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly FavoriteMediaKind[] _supportedMediaKinds =
|
||||
[
|
||||
FavoriteMediaKind.MusicArtist,
|
||||
FavoriteMediaKind.MusicAlbum,
|
||||
FavoriteMediaKind.MusicTrack,
|
||||
FavoriteMediaKind.Book
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="FavoriteItemDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="mediaKind">Optional kind of the favorited media item.</param>
|
||||
/// <param name="mediaItemId">Optional Id of the favorited media item.</param>
|
||||
/// <param name="isAvailable">Optional value indicating whether the media item still exists and can be accessed by the user.</param>
|
||||
/// <param name="libraryId">Optional Id of the media library that contains the media item.</param>
|
||||
/// <param name="title">Optional title of the media item.</param>
|
||||
/// <param name="collectionId">Optional Id of the collection that contains the media item.</param>
|
||||
/// <param name="collectionTitle">Optional title of the collection that contains the media item.</param>
|
||||
/// <param name="creatorId">Optional Id of the creator of the media item.</param>
|
||||
/// <param name="creatorName">Optional name of the creator of the media item.</param>
|
||||
/// <param name="coverPath">Optional path of the cover art of the media item.</param>
|
||||
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="FavoriteItemDto"/> instance.</returns>
|
||||
public FavoriteItemDto Create(
|
||||
FavoriteMediaKind? mediaKind = null,
|
||||
Guid? mediaItemId = null,
|
||||
bool? isAvailable = null,
|
||||
Guid? libraryId = null,
|
||||
string? title = null,
|
||||
Guid? collectionId = null,
|
||||
string? collectionTitle = null,
|
||||
Guid? creatorId = null,
|
||||
string? creatorName = null,
|
||||
string? coverPath = null,
|
||||
bool includeCoverPath = true)
|
||||
{
|
||||
return new FavoriteItemDto(
|
||||
MediaKind: mediaKind ?? _faker.PickRandom(_supportedMediaKinds),
|
||||
MediaItemId: mediaItemId ?? _faker.Random.Guid(),
|
||||
IsAvailable: isAvailable ?? _faker.Random.Bool(),
|
||||
LibraryId: libraryId ?? _faker.Random.Guid(),
|
||||
Title: title ?? _faker.Lorem.Sentence(3),
|
||||
CollectionId: collectionId ?? _faker.Random.Guid(),
|
||||
CollectionTitle: collectionTitle ?? _faker.Lorem.Sentence(3),
|
||||
CreatorId: creatorId ?? _faker.Random.Guid(),
|
||||
CreatorName: creatorName ?? _faker.Name.FullName(),
|
||||
CoverPath: includeCoverPath ? (coverPath ?? $"covers/{_faker.Random.AlphaNumeric(12)}.jpg") : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="FavoriteItemDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="FavoriteItemDto"/> instances.</returns>
|
||||
public List<FavoriteItemDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Favorites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Favorites;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="FavoriteStatusDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FavoriteStatusDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="FavoriteStatusDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="favoritedMediaItemIds">Optional Ids of the media items that are favorites of the current user.</param>
|
||||
/// <param name="mediaItemCount">Optional number of random favorited media item Ids to generate, between 0 and 5.</param>
|
||||
/// <returns>A configured <see cref="FavoriteStatusDto"/> instance.</returns>
|
||||
public FavoriteStatusDto Create(
|
||||
List<Guid>? favoritedMediaItemIds = null,
|
||||
int? mediaItemCount = null)
|
||||
{
|
||||
int resolvedCount = mediaItemCount ?? _faker.Random.Int(0, 5);
|
||||
return new FavoriteStatusDto(
|
||||
FavoritedMediaItemIds: favoritedMediaItemIds ?? [.. Enumerable.Range(0, resolvedCount).Select(_ => _faker.Random.Guid())]
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="FavoriteStatusDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="FavoriteStatusDto"/> instances.</returns>
|
||||
public List<FavoriteStatusDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="BlobDataDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BlobDataDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="BlobDataDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="data">Optional. The binary data as a byte array.</param>
|
||||
/// <param name="contentType">Optional. The content type (MIME type) of the blob data.</param>
|
||||
/// <returns>The created <see cref="BlobDataDto"/>.</returns>
|
||||
public BlobDataDto Create(
|
||||
byte[]? data = null,
|
||||
string? contentType = null)
|
||||
{
|
||||
return new BlobDataDto
|
||||
{
|
||||
Data = data ?? _faker.Random.Bytes(32),
|
||||
ContentType = contentType ?? _faker.System.MimeType()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="BlobDataDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="BlobDataDto"/> instances.</returns>
|
||||
public List<BlobDataDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="DirectoryDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class DirectoryDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="DirectoryDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="path">Optional. The full path to the directory.</param>
|
||||
/// <param name="name">Optional. The name of the directory.</param>
|
||||
/// <param name="isHidden">Optional. Whether the directory is hidden. If not provided, a random value is generated.</param>
|
||||
/// <param name="items">Optional. The children items of the directory.</param>
|
||||
/// <param name="includeItems">Whether the children items should be included, or forced to an empty collection.</param>
|
||||
/// <returns>The created <see cref="DirectoryDto"/>.</returns>
|
||||
public DirectoryDto Create(
|
||||
string? path = null,
|
||||
string? name = null,
|
||||
bool? isHidden = null,
|
||||
List<FileSystemItemDto>? items = null,
|
||||
bool includeItems = false)
|
||||
{
|
||||
string generatedPath = _faker.System.DirectoryPath();
|
||||
return new DirectoryDto
|
||||
{
|
||||
Path = path ?? generatedPath,
|
||||
Name = name ?? Path.GetFileName(generatedPath),
|
||||
DateCreated = _faker.Date.Past(),
|
||||
DateModified = _faker.Date.Recent(),
|
||||
IsHidden = isHidden ?? _faker.Random.Bool(),
|
||||
Items = includeItems ? (items ?? []) : []
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="DirectoryDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="DirectoryDto"/> instances.</returns>
|
||||
public List<DirectoryDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="FileDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FileDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="FileDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="path">Optional. The full path to the file.</param>
|
||||
/// <param name="name">Optional. The name of the file.</param>
|
||||
/// <param name="size">Optional. The size of the file, in bytes.</param>
|
||||
/// <param name="isHidden">Optional. Whether the file is hidden. If not provided, a random value is generated.</param>
|
||||
/// <returns>A configured <see cref="FileDto"/> instance.</returns>
|
||||
public FileDto Create(
|
||||
string? path = null,
|
||||
string? name = null,
|
||||
long? size = null,
|
||||
bool? isHidden = null)
|
||||
{
|
||||
string generatedPath = _faker.System.FilePath();
|
||||
return new FileDto
|
||||
{
|
||||
Path = path ?? generatedPath,
|
||||
Name = name ?? Path.GetFileName(generatedPath),
|
||||
DateCreated = _faker.Date.Past(),
|
||||
DateModified = _faker.Date.Recent(),
|
||||
IsHidden = isHidden ?? _faker.Random.Bool(),
|
||||
Size = size ?? _faker.Random.Long(0, 10_000_000)
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="FileDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="FileDto"/> instances.</returns>
|
||||
public List<FileDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||
using Lumina.Presentation.Web.Common.Enums.FileSystem;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="FileSystemTreeNodeDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FileSystemTreeNodeDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="FileSystemTreeNodeDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="path">Optional. The full path of the file or directory.</param>
|
||||
/// <param name="name">Optional. The name of the file or directory.</param>
|
||||
/// <param name="itemType">Optional. The type of the item, indicating whether it is a file, directory, or drive.</param>
|
||||
/// <param name="isHidden">Optional. Whether the node is hidden. If not provided, a random value is generated.</param>
|
||||
/// <returns>A configured <see cref="FileSystemTreeNodeDto"/> instance.</returns>
|
||||
public FileSystemTreeNodeDto Create(
|
||||
string? path = null,
|
||||
string? name = null,
|
||||
FileSystemItemType? itemType = null,
|
||||
bool? isHidden = null)
|
||||
{
|
||||
string generatedPath = _faker.System.FilePath();
|
||||
return new FileSystemTreeNodeDto
|
||||
{
|
||||
Path = path ?? generatedPath,
|
||||
Name = name ?? Path.GetFileName(generatedPath),
|
||||
ItemType = itemType ?? _faker.PickRandom<FileSystemItemType>(),
|
||||
IsHidden = isHidden ?? _faker.Random.Bool(),
|
||||
IsExpanded = _faker.Random.Bool(),
|
||||
ChildrenLoaded = _faker.Random.Bool(),
|
||||
Children = []
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="FileSystemTreeNodeDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="FileSystemTreeNodeDto"/> instances.</returns>
|
||||
public List<FileSystemTreeNodeDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||
using Lumina.Presentation.Web.Common.Enums.FileSystem;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="FileSystemTypeDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FileSystemTypeDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="FileSystemTypeDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="platformType">Optional file system platform type.</param>
|
||||
/// <returns>A configured <see cref="FileSystemTypeDto"/> instance.</returns>
|
||||
public FileSystemTypeDto Create(
|
||||
PlatformType? platformType = null)
|
||||
{
|
||||
return new FileSystemTypeDto
|
||||
{
|
||||
PlatformType = platformType ?? _faker.PickRandom<PlatformType>()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="FileSystemTypeDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="FileSystemTypeDto"/> instances.</returns>
|
||||
public List<FileSystemTypeDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PathExistsDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PathExistsDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="PathExistsDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="exists">Optional value indicating whether a file system path exists or not.</param>
|
||||
/// <returns>A configured <see cref="PathExistsDto"/> instance.</returns>
|
||||
public PathExistsDto Create(
|
||||
bool? exists = null)
|
||||
{
|
||||
return new PathExistsDto(
|
||||
Exists: exists ?? _faker.Random.Bool()
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="PathExistsDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PathExistsDto"/> instances.</returns>
|
||||
public List<PathExistsDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PathSegmentDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PathSegmentDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="PathSegmentDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="path">Optional. The returned path.</param>
|
||||
/// <returns>A configured <see cref="PathSegmentDto"/> instance.</returns>
|
||||
public PathSegmentDto Create(
|
||||
string? path = null)
|
||||
{
|
||||
return new PathSegmentDto
|
||||
{
|
||||
Path = path ?? _faker.System.FilePath()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="PathSegmentDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PathSegmentDto"/> instances.</returns>
|
||||
public List<PathSegmentDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PathSeparatorDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PathSeparatorDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="PathSeparatorDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="separator">Optional file system path separator.</param>
|
||||
/// <returns>A configured <see cref="PathSeparatorDto"/> instance.</returns>
|
||||
public PathSeparatorDto Create(
|
||||
string? separator = null)
|
||||
{
|
||||
return new PathSeparatorDto(
|
||||
Separator: separator ?? (_faker.Random.Bool() ? "\\" : "/")
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="PathSeparatorDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PathSeparatorDto"/> instances.</returns>
|
||||
public List<PathSeparatorDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PathValidDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PathValidDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="PathValidDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="isValid">Optional value indicating whether a file system path is valid or not.</param>
|
||||
/// <returns>A configured <see cref="PathValidDto"/> instance.</returns>
|
||||
public PathValidDto Create(
|
||||
bool? isValid = null)
|
||||
{
|
||||
return new PathValidDto(
|
||||
IsValid: isValid ?? _faker.Random.Bool()
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="PathValidDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PathValidDto"/> instances.</returns>
|
||||
public List<PathValidDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="BookLiteDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BookLiteDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="BookLiteDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the book.</param>
|
||||
/// <param name="title">Optional. The title of the book.</param>
|
||||
/// <param name="releaseYear">Optional. The release year of the book.</param>
|
||||
/// <param name="coverPath">Optional. The path of the image representing the cover of the book.</param>
|
||||
/// <param name="includeReleaseYear">Whether the release year should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="BookLiteDto"/>.</returns>
|
||||
public BookLiteDto Create(
|
||||
Guid? id = null,
|
||||
string? title = null,
|
||||
int? releaseYear = null,
|
||||
string? coverPath = null,
|
||||
bool includeReleaseYear = false,
|
||||
bool includeCoverPath = false)
|
||||
{
|
||||
return new BookLiteDto
|
||||
{
|
||||
Id = id ?? _faker.Random.Guid(),
|
||||
Title = title ?? _faker.Lorem.Sentence(3),
|
||||
ReleaseYear = includeReleaseYear ? (releaseYear ?? _faker.Random.Int(1900, 2024)) : null,
|
||||
CoverPath = includeCoverPath ? (coverPath ?? _faker.System.FilePath()) : null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="BookLiteDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="BookLiteDto"/> instances.</returns>
|
||||
public List<BookLiteDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="LibraryDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional identifier of the media library.</param>
|
||||
/// <param name="title">Optional title of the library.</param>
|
||||
/// <param name="libraryType">Optional type of the library.</param>
|
||||
/// <param name="isEnabled">Whether the media library is enabled or not.</param>
|
||||
/// <param name="contentLocations">Optional collection of directories that contain the library files.</param>
|
||||
/// <param name="shouldSkipHiddenFilesAndDirectoriesDuringScan">Optional. Whether hidden files and directories should be skipped during the scan, or not.</param>
|
||||
/// <returns>A configured <see cref="LibraryDto"/> instance.</returns>
|
||||
public LibraryDto Create(
|
||||
Guid? id = null,
|
||||
string? title = null,
|
||||
string? libraryType = null,
|
||||
bool? isEnabled = null,
|
||||
List<string>? contentLocations = null,
|
||||
bool? shouldSkipHiddenFilesAndDirectoriesDuringScan = null)
|
||||
{
|
||||
return new LibraryDto
|
||||
{
|
||||
Id = id ?? Guid.NewGuid(),
|
||||
Title = title ?? _faker.Commerce.Department(),
|
||||
LibraryType = libraryType ?? _faker.PickRandom("Book", "Video", "Photo"),
|
||||
CoverImage = _faker.Image.PicsumUrl(),
|
||||
ContentLocations = contentLocations ?? [_faker.System.DirectoryPath()],
|
||||
IsEnabled = isEnabled ?? _faker.Random.Bool(),
|
||||
ShouldSkipHiddenFilesAndDirectoriesDuringScan = shouldSkipHiddenFilesAndDirectoriesDuringScan ?? _faker.Random.Bool()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="LibraryDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="LibraryDto"/> instances.</returns>
|
||||
public List<LibraryDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryPathPartDefinitionDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryPathPartDefinitionDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="LibraryPathPartDefinitionDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="kind">Optional kind of the path part.</param>
|
||||
/// <param name="valueType">Optional value type captured by the path part.</param>
|
||||
/// <param name="defaultRepresentation">Optional default representation of the path part.</param>
|
||||
/// <param name="isOptionalByDefault">Optional value indicating whether the path part is optional by default.</param>
|
||||
/// <returns>A configured <see cref="LibraryPathPartDefinitionDto"/> instance.</returns>
|
||||
public LibraryPathPartDefinitionDto Create(
|
||||
string? kind = null,
|
||||
string? valueType = null,
|
||||
string? defaultRepresentation = null,
|
||||
bool? isOptionalByDefault = null)
|
||||
{
|
||||
return new LibraryPathPartDefinitionDto
|
||||
{
|
||||
Kind = kind ?? _faker.Random.Word(),
|
||||
ValueType = valueType ?? _faker.Random.Word(),
|
||||
DefaultRepresentation = defaultRepresentation ?? "{0}",
|
||||
IsOptionalByDefault = isOptionalByDefault ?? _faker.Random.Bool()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="LibraryPathPartDefinitionDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="LibraryPathPartDefinitionDto"/> instances.</returns>
|
||||
public List<LibraryPathPartDefinitionDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryPathTemplateCatalogDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryPathTemplateCatalogDtoFixture
|
||||
{
|
||||
private readonly LibraryPathPartDefinitionDtoFixture _libraryPathPartDefinitionDtoFixture = new();
|
||||
private readonly LibraryPathTemplatePartDtoFixture _libraryPathTemplatePartDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="LibraryPathTemplateCatalogDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="parts">Optional path parts that can be used in the path template of the library type.</param>
|
||||
/// <param name="defaultTemplateParts">Optional ordered parts of the default path template of the library type.</param>
|
||||
/// <param name="includeParts">Whether the catalog should carry selectable path parts. When <see langword="false"/>, the parts are forced to an empty collection.</param>
|
||||
/// <param name="includeDefaultTemplateParts">Whether the catalog should carry default template parts. When <see langword="false"/>, the default template parts are forced to an empty collection.</param>
|
||||
/// <returns>A configured <see cref="LibraryPathTemplateCatalogDto"/> instance.</returns>
|
||||
public LibraryPathTemplateCatalogDto Create(
|
||||
List<LibraryPathPartDefinitionDto>? parts = null,
|
||||
List<LibraryPathTemplatePartDto>? defaultTemplateParts = null,
|
||||
bool includeParts = true,
|
||||
bool includeDefaultTemplateParts = true)
|
||||
{
|
||||
return new LibraryPathTemplateCatalogDto
|
||||
{
|
||||
Parts = includeParts ? (parts ?? _libraryPathPartDefinitionDtoFixture.CreateMany(2)) : [],
|
||||
DefaultTemplateParts = includeDefaultTemplateParts ? (defaultTemplateParts ?? _libraryPathTemplatePartDtoFixture.CreateMany(2)) : []
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="LibraryPathTemplateCatalogDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="LibraryPathTemplateCatalogDto"/> instances.</returns>
|
||||
public List<LibraryPathTemplateCatalogDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryPathTemplatePartDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryPathTemplatePartDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="LibraryPathTemplatePartDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="kind">Optional kind of the path part.</param>
|
||||
/// <param name="representation">Optional literal text or value mask of the path part.</param>
|
||||
/// <param name="isOptional">Optional value indicating whether the path part can be absent from the path.</param>
|
||||
/// <returns>A configured <see cref="LibraryPathTemplatePartDto"/> instance.</returns>
|
||||
public LibraryPathTemplatePartDto Create(
|
||||
string? kind = null,
|
||||
string? representation = null,
|
||||
bool? isOptional = null)
|
||||
{
|
||||
return new LibraryPathTemplatePartDto
|
||||
{
|
||||
Kind = kind ?? _faker.Random.Word(),
|
||||
Representation = representation ?? "{0}",
|
||||
IsOptional = isOptional ?? _faker.Random.Bool()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="LibraryPathTemplatePartDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="LibraryPathTemplatePartDto"/> instances.</returns>
|
||||
public List<LibraryPathTemplatePartDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryProviderSelectionDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryProviderSelectionDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryProviderSelectionDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="pluginId">Optional. The Id of the plugin providing the provider or reader.</param>
|
||||
/// <param name="isEnabled">Optional. Whether the provider or reader is enabled.</param>
|
||||
/// <param name="includeIsEnabled">Whether the choice carries an enabled state. When <see langword="false"/>, the enabled state is <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="LibraryProviderSelectionDto"/>.</returns>
|
||||
public LibraryProviderSelectionDto Create(
|
||||
Guid? pluginId = null,
|
||||
bool? isEnabled = null,
|
||||
bool includeIsEnabled = true)
|
||||
{
|
||||
return new LibraryProviderSelectionDto
|
||||
{
|
||||
PluginId = pluginId ?? Guid.NewGuid(),
|
||||
IsEnabled = includeIsEnabled ? isEnabled ?? _faker.Random.Bool() : null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="LibraryProviderSelectionDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<LibraryProviderSelectionDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryScanJobProgressDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryScanJobProgressDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="LibraryScanJobProgressDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="completedItems">Optional number of completed items of the media library scan job.</param>
|
||||
/// <param name="totalItems">Optional total number of items of the media library scan job.</param>
|
||||
/// <param name="currentOperation">Optional current operation being performed by the media library scan job.</param>
|
||||
/// <param name="progressPercentage">Optional completion ratio of the media library scan job, as a percentage.</param>
|
||||
/// <returns>A configured <see cref="LibraryScanJobProgressDto"/> instance.</returns>
|
||||
public LibraryScanJobProgressDto Create(
|
||||
int? completedItems = null,
|
||||
int? totalItems = null,
|
||||
string? currentOperation = null,
|
||||
decimal? progressPercentage = null)
|
||||
{
|
||||
int completed = completedItems ?? _faker.Random.Int(0, 100);
|
||||
int total = totalItems ?? _faker.Random.Int(completed, 100);
|
||||
return new LibraryScanJobProgressDto
|
||||
{
|
||||
CompletedItems = completed,
|
||||
TotalItems = total,
|
||||
CurrentOperation = currentOperation ?? _faker.Hacker.Verb(),
|
||||
ProgressPercentage = progressPercentage ?? (total > 0 ? (decimal)completed / total * 100 : 0)
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="LibraryScanJobProgressDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="LibraryScanJobProgressDto"/> instances.</returns>
|
||||
public List<LibraryScanJobProgressDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryScanProgressDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryScanProgressDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
private readonly LibraryScanJobProgressDtoFixture _libraryScanJobProgressDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="LibraryScanProgressDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="scanId">Optional unique identifier of the media library scan.</param>
|
||||
/// <param name="userId">Optional unique identifier of the user initiating the media library scan.</param>
|
||||
/// <param name="libraryId">Optional unique identifier of the media library that is scanned.</param>
|
||||
/// <param name="completedJobs">Optional number of completed jobs of the media library scan job.</param>
|
||||
/// <param name="totalJobs">Optional total number of jobs of the media library scan job.</param>
|
||||
/// <param name="status">Optional status of the media library scan.</param>
|
||||
/// <param name="includeCurrentJobProgress">Whether the current job progress should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="LibraryScanProgressDto"/> instance.</returns>
|
||||
public LibraryScanProgressDto Create(
|
||||
Guid? scanId = null,
|
||||
Guid? userId = null,
|
||||
Guid? libraryId = null,
|
||||
int? completedJobs = null,
|
||||
int? totalJobs = null,
|
||||
string? status = null,
|
||||
bool includeCurrentJobProgress = false)
|
||||
{
|
||||
int completed = completedJobs ?? _faker.Random.Int(0, 10);
|
||||
int total = totalJobs ?? _faker.Random.Int(completed, 10);
|
||||
return new LibraryScanProgressDto
|
||||
{
|
||||
ScanId = scanId ?? Guid.NewGuid(),
|
||||
UserId = userId ?? Guid.NewGuid(),
|
||||
LibraryId = libraryId ?? Guid.NewGuid(),
|
||||
CompletedJobs = completed,
|
||||
TotalJobs = total,
|
||||
CurrentJobProgress = includeCurrentJobProgress ? _libraryScanJobProgressDtoFixture.Create() : null,
|
||||
Status = status ?? _faker.PickRandom("Running", "Completed", "Failed"),
|
||||
OverallProgressPercentage = total > 0 ? (decimal)completed / total * 100 : 0
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="LibraryScanProgressDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="LibraryScanProgressDto"/> instances.</returns>
|
||||
public List<LibraryScanProgressDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ScanLibraryDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ScanLibraryDtoFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ScanLibraryDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="scanId">Optional Id of the media library scan.</param>
|
||||
/// <param name="libraryId">Optional Id of the scanned media library.</param>
|
||||
/// <returns>A configured <see cref="ScanLibraryDto"/> instance.</returns>
|
||||
public ScanLibraryDto Create(
|
||||
Guid? scanId = null,
|
||||
Guid? libraryId = null)
|
||||
{
|
||||
return new ScanLibraryDto
|
||||
{
|
||||
ScanId = scanId ?? Guid.NewGuid(),
|
||||
LibraryId = libraryId ?? Guid.NewGuid()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="ScanLibraryDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ScanLibraryDto"/> instances.</returns>
|
||||
public List<ScanLibraryDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.DTO.MediaConsumption;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AllUsersConsumptionStatisticsDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AllUsersConsumptionStatisticsDtoFixture
|
||||
{
|
||||
private readonly ConsumptionTotalsDtoFixture _consumptionTotalsDtoFixture = new();
|
||||
private readonly ConsumptionSummaryDtoFixture _consumptionSummaryDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="AllUsersConsumptionStatisticsDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="total">Optional combined consumption statistics of every user.</param>
|
||||
/// <param name="users">Optional consumption statistics of each user.</param>
|
||||
/// <param name="includeUsers">Whether the per user statistics should be included, or forced to an empty collection.</param>
|
||||
/// <returns>A configured <see cref="AllUsersConsumptionStatisticsDto"/> instance.</returns>
|
||||
public AllUsersConsumptionStatisticsDto Create(
|
||||
ConsumptionTotalsDto? total = null,
|
||||
IReadOnlyList<ConsumptionSummaryDto>? users = null,
|
||||
bool includeUsers = true)
|
||||
{
|
||||
return new AllUsersConsumptionStatisticsDto(
|
||||
Total: total ?? _consumptionTotalsDtoFixture.Create(),
|
||||
Users: includeUsers ? (users ?? [.. _consumptionSummaryDtoFixture.CreateMany(2)]) : []
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="AllUsersConsumptionStatisticsDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="AllUsersConsumptionStatisticsDto"/> instances.</returns>
|
||||
public List<AllUsersConsumptionStatisticsDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.MediaConsumption;
|
||||
using Lumina.Presentation.Web.Common.Enums.MediaConsumption;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ConsumedItemDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ConsumedItemDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ConsumedItemDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="mediaKind">Optional kind of the consumed media item.</param>
|
||||
/// <param name="mediaItemId">Optional Id of the consumed media item.</param>
|
||||
/// <param name="libraryId">Optional Id of the media library that contains the media item.</param>
|
||||
/// <param name="isAvailable">Optional value indicating whether the media item is still available.</param>
|
||||
/// <param name="title">Optional title of the media item.</param>
|
||||
/// <param name="collectionTitle">Optional title of the collection that contains the media item.</param>
|
||||
/// <param name="creatorName">Optional name of the creator of the media item.</param>
|
||||
/// <param name="coverPath">Optional path of the cover art of the media item.</param>
|
||||
/// <param name="lastConsumedOnUtc">Optional date and time when the media item was last consumed.</param>
|
||||
/// <param name="countedSessionCount">Optional number of counted sessions.</param>
|
||||
/// <param name="completedSessionCount">Optional number of completed sessions.</param>
|
||||
/// <param name="consumedDurationInSeconds">Optional consumed duration, in seconds.</param>
|
||||
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="ConsumedItemDto"/> instance.</returns>
|
||||
public ConsumedItemDto Create(
|
||||
MediaKind? mediaKind = null,
|
||||
Guid? mediaItemId = null,
|
||||
Guid? libraryId = null,
|
||||
bool? isAvailable = null,
|
||||
string? title = null,
|
||||
string? collectionTitle = null,
|
||||
string? creatorName = null,
|
||||
string? coverPath = null,
|
||||
DateTime? lastConsumedOnUtc = null,
|
||||
int? countedSessionCount = null,
|
||||
int? completedSessionCount = null,
|
||||
double? consumedDurationInSeconds = null,
|
||||
bool includeCoverPath = true)
|
||||
{
|
||||
return new ConsumedItemDto(
|
||||
MediaKind: mediaKind ?? _faker.PickRandom(MediaKind.MusicTrack, MediaKind.PodcastEpisode, MediaKind.Audiobook, MediaKind.Movie, MediaKind.TvEpisode, MediaKind.Book, MediaKind.Photo, MediaKind.Video),
|
||||
MediaItemId: mediaItemId ?? _faker.Random.Guid(),
|
||||
LibraryId: libraryId ?? _faker.Random.Guid(),
|
||||
IsAvailable: isAvailable ?? _faker.Random.Bool(),
|
||||
Title: title ?? _faker.Lorem.Sentence(),
|
||||
CollectionTitle: collectionTitle ?? _faker.Lorem.Sentence(),
|
||||
CreatorName: creatorName ?? _faker.Name.FullName(),
|
||||
CoverPath: includeCoverPath ? (coverPath ?? _faker.System.FilePath()) : null,
|
||||
LastConsumedOnUtc: lastConsumedOnUtc ?? _faker.Date.Between(new DateTime(2024, 1, 1), new DateTime(2025, 12, 31)),
|
||||
CountedSessionCount: countedSessionCount ?? _faker.Random.Int(0, 1000),
|
||||
CompletedSessionCount: completedSessionCount ?? _faker.Random.Int(0, 1000),
|
||||
ConsumedDurationInSeconds: consumedDurationInSeconds ?? _faker.Random.Double(0, 100000)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="ConsumedItemDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ConsumedItemDto"/> instances.</returns>
|
||||
public List<ConsumedItemDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.MediaConsumption;
|
||||
using Lumina.Presentation.Web.Common.Enums.MediaConsumption;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ConsumptionRecordDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ConsumptionRecordDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly MediaPositionDtoFixture _mediaPositionDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ConsumptionRecordDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional Id of the consumption record.</param>
|
||||
/// <param name="libraryId">Optional Id of the media library that contains the consumed media item.</param>
|
||||
/// <param name="mediaItemId">Optional Id of the consumed media item.</param>
|
||||
/// <param name="mediaKind">Optional kind of media that was consumed.</param>
|
||||
/// <param name="status">Optional state of the consumption session.</param>
|
||||
/// <param name="startedOnUtc">Optional date and time when the session started.</param>
|
||||
/// <param name="lastActivityOnUtc">Optional date and time when the session last received activity.</param>
|
||||
/// <param name="endedOnUtc">Optional date and time when the session completed or stopped.</param>
|
||||
/// <param name="consumedDurationInSeconds">Optional active duration consumed by the session, in seconds.</param>
|
||||
/// <param name="lastPosition">Optional last known position for the media item.</param>
|
||||
/// <param name="lastProgressFraction">Optional latest reported progress fraction of the media item.</param>
|
||||
/// <param name="consecutivePagesRead">Optional number of consecutive pages read in the session.</param>
|
||||
/// <param name="includeEndedOnUtc">Whether the end date should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeLastPosition">Whether the last position should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="ConsumptionRecordDto"/> instance.</returns>
|
||||
public ConsumptionRecordDto Create(
|
||||
Guid? id = null,
|
||||
Guid? libraryId = null,
|
||||
Guid? mediaItemId = null,
|
||||
MediaKind? mediaKind = null,
|
||||
ConsumptionStatus? status = null,
|
||||
DateTime? startedOnUtc = null,
|
||||
DateTime? lastActivityOnUtc = null,
|
||||
DateTime? endedOnUtc = null,
|
||||
double? consumedDurationInSeconds = null,
|
||||
MediaPositionDto? lastPosition = null,
|
||||
double? lastProgressFraction = null,
|
||||
int? consecutivePagesRead = null,
|
||||
bool includeEndedOnUtc = true,
|
||||
bool includeLastPosition = true)
|
||||
{
|
||||
DateTime resolvedStartedOnUtc = DateTime.SpecifyKind(startedOnUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)), DateTimeKind.Utc);
|
||||
DateTime resolvedLastActivityOnUtc = DateTime.SpecifyKind(lastActivityOnUtc ?? resolvedStartedOnUtc.AddSeconds(_faker.Random.Int(0, 3600)), DateTimeKind.Utc);
|
||||
DateTime resolvedEndedOnUtc = DateTime.SpecifyKind(endedOnUtc ?? resolvedLastActivityOnUtc.AddSeconds(_faker.Random.Int(0, 3600)), DateTimeKind.Utc);
|
||||
return new ConsumptionRecordDto(
|
||||
Id: id ?? _faker.Random.Guid(),
|
||||
LibraryId: libraryId ?? _faker.Random.Guid(),
|
||||
MediaItemId: mediaItemId ?? _faker.Random.Guid(),
|
||||
MediaKind: mediaKind ?? _faker.PickRandom(MediaKind.MusicTrack, MediaKind.PodcastEpisode, MediaKind.Audiobook, MediaKind.Movie, MediaKind.TvEpisode, MediaKind.Book, MediaKind.Photo, MediaKind.Video),
|
||||
Status: status ?? _faker.PickRandom(ConsumptionStatus.InProgress, ConsumptionStatus.Completed, ConsumptionStatus.Stopped),
|
||||
StartedOnUtc: resolvedStartedOnUtc,
|
||||
LastActivityOnUtc: resolvedLastActivityOnUtc,
|
||||
EndedOnUtc: includeEndedOnUtc ? resolvedEndedOnUtc : null,
|
||||
ConsumedDurationInSeconds: consumedDurationInSeconds ?? _faker.Random.Double(0, 100000),
|
||||
LastPosition: includeLastPosition ? (lastPosition ?? _mediaPositionDtoFixture.Create()) : null,
|
||||
LastProgressFraction: lastProgressFraction ?? _faker.Random.Double(0, 1),
|
||||
ConsecutivePagesRead: consecutivePagesRead ?? _faker.Random.Int(0, 1000)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="ConsumptionRecordDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ConsumptionRecordDto"/> instances.</returns>
|
||||
public List<ConsumptionRecordDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.MediaConsumption;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ConsumptionSummaryDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ConsumptionSummaryDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly MediaKindConsumptionSummaryDtoFixture _mediaKindConsumptionSummaryDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ConsumptionSummaryDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="userId">Optional Id of the user the statistics belong to.</param>
|
||||
/// <param name="totalConsumedDurationInSeconds">Optional total consumed duration, in seconds.</param>
|
||||
/// <param name="countedSessionCount">Optional number of counted sessions.</param>
|
||||
/// <param name="completedSessionCount">Optional number of completed sessions.</param>
|
||||
/// <param name="stoppedSessionCount">Optional number of stopped sessions.</param>
|
||||
/// <param name="completionRate">Optional fraction of the counted sessions that completed.</param>
|
||||
/// <param name="mediaKindSummaries">Optional consumption statistics broken down by media kind.</param>
|
||||
/// <param name="includeMediaKindSummaries">Whether the media kind summaries should be included, or forced to an empty collection.</param>
|
||||
/// <returns>A configured <see cref="ConsumptionSummaryDto"/> instance.</returns>
|
||||
public ConsumptionSummaryDto Create(
|
||||
Guid? userId = null,
|
||||
double? totalConsumedDurationInSeconds = null,
|
||||
int? countedSessionCount = null,
|
||||
int? completedSessionCount = null,
|
||||
int? stoppedSessionCount = null,
|
||||
double? completionRate = null,
|
||||
IReadOnlyList<MediaKindConsumptionSummaryDto>? mediaKindSummaries = null,
|
||||
bool includeMediaKindSummaries = true)
|
||||
{
|
||||
return new ConsumptionSummaryDto(
|
||||
UserId: userId ?? _faker.Random.Guid(),
|
||||
TotalConsumedDurationInSeconds: totalConsumedDurationInSeconds ?? _faker.Random.Double(0, 100000),
|
||||
CountedSessionCount: countedSessionCount ?? _faker.Random.Int(0, 1000),
|
||||
CompletedSessionCount: completedSessionCount ?? _faker.Random.Int(0, 1000),
|
||||
StoppedSessionCount: stoppedSessionCount ?? _faker.Random.Int(0, 1000),
|
||||
CompletionRate: completionRate ?? _faker.Random.Double(0, 1),
|
||||
MediaKindSummaries: includeMediaKindSummaries ? (mediaKindSummaries ?? [.. _mediaKindConsumptionSummaryDtoFixture.CreateMany(2)]) : []
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="ConsumptionSummaryDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ConsumptionSummaryDto"/> instances.</returns>
|
||||
public List<ConsumptionSummaryDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.MediaConsumption;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ConsumptionTotalsDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ConsumptionTotalsDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly MediaKindConsumptionSummaryDtoFixture _mediaKindConsumptionSummaryDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ConsumptionTotalsDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="totalConsumedDurationInSeconds">Optional total consumed duration, in seconds.</param>
|
||||
/// <param name="countedSessionCount">Optional number of counted sessions.</param>
|
||||
/// <param name="completedSessionCount">Optional number of completed sessions.</param>
|
||||
/// <param name="stoppedSessionCount">Optional number of stopped sessions.</param>
|
||||
/// <param name="completionRate">Optional fraction of the counted sessions that completed.</param>
|
||||
/// <param name="mediaKindSummaries">Optional consumption statistics broken down by media kind.</param>
|
||||
/// <param name="includeMediaKindSummaries">Whether the media kind summaries should be included, or forced to an empty collection.</param>
|
||||
/// <returns>A configured <see cref="ConsumptionTotalsDto"/> instance.</returns>
|
||||
public ConsumptionTotalsDto Create(
|
||||
double? totalConsumedDurationInSeconds = null,
|
||||
int? countedSessionCount = null,
|
||||
int? completedSessionCount = null,
|
||||
int? stoppedSessionCount = null,
|
||||
double? completionRate = null,
|
||||
IReadOnlyList<MediaKindConsumptionSummaryDto>? mediaKindSummaries = null,
|
||||
bool includeMediaKindSummaries = true)
|
||||
{
|
||||
return new ConsumptionTotalsDto(
|
||||
TotalConsumedDurationInSeconds: totalConsumedDurationInSeconds ?? _faker.Random.Double(0, 100000),
|
||||
CountedSessionCount: countedSessionCount ?? _faker.Random.Int(0, 1000),
|
||||
CompletedSessionCount: completedSessionCount ?? _faker.Random.Int(0, 1000),
|
||||
StoppedSessionCount: stoppedSessionCount ?? _faker.Random.Int(0, 1000),
|
||||
CompletionRate: completionRate ?? _faker.Random.Double(0, 1),
|
||||
MediaKindSummaries: includeMediaKindSummaries ? (mediaKindSummaries ?? [.. _mediaKindConsumptionSummaryDtoFixture.CreateMany(2)]) : []
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="ConsumptionTotalsDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ConsumptionTotalsDto"/> instances.</returns>
|
||||
public List<ConsumptionTotalsDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.MediaConsumption;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GenreConsumptionDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GenreConsumptionDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="GenreConsumptionDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="name">Optional lowercase name of the genre.</param>
|
||||
/// <param name="consumedItemCount">Optional number of distinct consumed media items that carry the genre.</param>
|
||||
/// <param name="consumedDurationInSeconds">Optional consumed duration, in seconds.</param>
|
||||
/// <returns>A configured <see cref="GenreConsumptionDto"/> instance.</returns>
|
||||
public GenreConsumptionDto Create(
|
||||
string? name = null,
|
||||
int? consumedItemCount = null,
|
||||
double? consumedDurationInSeconds = null)
|
||||
{
|
||||
return new GenreConsumptionDto(
|
||||
Name: name ?? _faker.Lorem.Word().ToLowerInvariant(),
|
||||
ConsumedItemCount: consumedItemCount ?? _faker.Random.Int(0, 1000),
|
||||
ConsumedDurationInSeconds: consumedDurationInSeconds ?? _faker.Random.Double(0, 100000)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="GenreConsumptionDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GenreConsumptionDto"/> instances.</returns>
|
||||
public List<GenreConsumptionDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.MediaConsumption;
|
||||
using Lumina.Presentation.Web.Common.Enums.MediaConsumption;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaKindConsumptionSummaryDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaKindConsumptionSummaryDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="MediaKindConsumptionSummaryDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="mediaKind">Optional kind of media the statistics belong to.</param>
|
||||
/// <param name="totalConsumedDurationInSeconds">Optional total consumed duration, in seconds.</param>
|
||||
/// <param name="countedSessionCount">Optional number of counted sessions.</param>
|
||||
/// <param name="completedSessionCount">Optional number of completed sessions.</param>
|
||||
/// <param name="stoppedSessionCount">Optional number of stopped sessions.</param>
|
||||
/// <param name="completionRate">Optional fraction of the counted sessions that completed.</param>
|
||||
/// <returns>A configured <see cref="MediaKindConsumptionSummaryDto"/> instance.</returns>
|
||||
public MediaKindConsumptionSummaryDto Create(
|
||||
MediaKind? mediaKind = null,
|
||||
double? totalConsumedDurationInSeconds = null,
|
||||
int? countedSessionCount = null,
|
||||
int? completedSessionCount = null,
|
||||
int? stoppedSessionCount = null,
|
||||
double? completionRate = null)
|
||||
{
|
||||
return new MediaKindConsumptionSummaryDto(
|
||||
MediaKind: mediaKind ?? _faker.PickRandom(MediaKind.MusicTrack, MediaKind.PodcastEpisode, MediaKind.Audiobook, MediaKind.Movie, MediaKind.TvEpisode, MediaKind.Book, MediaKind.Photo, MediaKind.Video),
|
||||
TotalConsumedDurationInSeconds: totalConsumedDurationInSeconds ?? _faker.Random.Double(0, 100000),
|
||||
CountedSessionCount: countedSessionCount ?? _faker.Random.Int(0, 1000),
|
||||
CompletedSessionCount: completedSessionCount ?? _faker.Random.Int(0, 1000),
|
||||
StoppedSessionCount: stoppedSessionCount ?? _faker.Random.Int(0, 1000),
|
||||
CompletionRate: completionRate ?? _faker.Random.Double(0, 1)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MediaKindConsumptionSummaryDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaKindConsumptionSummaryDto"/> instances.</returns>
|
||||
public List<MediaKindConsumptionSummaryDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.MediaConsumption;
|
||||
using Lumina.Presentation.Web.Common.Enums.MediaConsumption;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaPositionDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaPositionDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="MediaPositionDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="kind">Optional kind of representation used by the position.</param>
|
||||
/// <param name="timeOffsetSeconds">Optional position within the media item, in seconds.</param>
|
||||
/// <param name="location">Optional opaque locator within the media item.</param>
|
||||
/// <param name="includeTimeOffsetSeconds">Whether the time offset should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeLocation">Whether the location should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="MediaPositionDto"/> instance.</returns>
|
||||
public MediaPositionDto Create(
|
||||
MediaPositionKind? kind = null,
|
||||
double? timeOffsetSeconds = null,
|
||||
string? location = null,
|
||||
bool includeTimeOffsetSeconds = true,
|
||||
bool includeLocation = true)
|
||||
{
|
||||
MediaPositionKind resolvedKind = kind ?? _faker.PickRandom(MediaPositionKind.TimeOffset, MediaPositionKind.Location);
|
||||
return new MediaPositionDto(
|
||||
Kind: resolvedKind,
|
||||
TimeOffsetSeconds: includeTimeOffsetSeconds
|
||||
? (timeOffsetSeconds ?? (resolvedKind == MediaPositionKind.TimeOffset ? _faker.Random.Double(0, 100000) : null))
|
||||
: null,
|
||||
Location: includeLocation
|
||||
? (location ?? (resolvedKind == MediaPositionKind.Location ? _faker.Random.AlphaNumeric(24) : null))
|
||||
: null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MediaPositionDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaPositionDto"/> instances.</returns>
|
||||
public List<MediaPositionDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.MediaConsumption;
|
||||
using Lumina.Presentation.Web.Common.Enums.MediaConsumption;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ResumePointDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ResumePointDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly MediaPositionDtoFixture _mediaPositionDtoFixture = new();
|
||||
private readonly MediaKind[] _resumableMediaKinds =
|
||||
[
|
||||
MediaKind.MusicTrack,
|
||||
MediaKind.PodcastEpisode,
|
||||
MediaKind.Audiobook,
|
||||
MediaKind.Movie,
|
||||
MediaKind.TvEpisode,
|
||||
MediaKind.Book,
|
||||
MediaKind.Video
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ResumePointDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the resume point.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library that contains the media item.</param>
|
||||
/// <param name="mediaItemId">Optional. The Id of the media item to resume.</param>
|
||||
/// <param name="mediaKind">Optional. The kind of media that is resumed. Defaults to a random resumable kind.</param>
|
||||
/// <param name="lastPosition">Optional. The position at which the media item can be resumed. Defaults to a position matching the position kind of the media kind.</param>
|
||||
/// <param name="lastProgressFraction">Optional. The progress fraction at which the media item can be resumed. Defaults to a bounded random fraction between zero and one.</param>
|
||||
/// <param name="lastConsumedOnUtc">Optional. The date and time when the media item was last consumed. Defaults to a moment in the past.</param>
|
||||
/// <returns>A configured <see cref="ResumePointDto"/> instance.</returns>
|
||||
public ResumePointDto Create(
|
||||
Guid? id = null,
|
||||
Guid? libraryId = null,
|
||||
Guid? mediaItemId = null,
|
||||
MediaKind? mediaKind = null,
|
||||
MediaPositionDto? lastPosition = null,
|
||||
double? lastProgressFraction = null,
|
||||
DateTime? lastConsumedOnUtc = null)
|
||||
{
|
||||
MediaKind resolvedMediaKind = mediaKind ?? _faker.Random.ArrayElement(_resumableMediaKinds);
|
||||
|
||||
return new ResumePointDto(
|
||||
id ?? _faker.Random.Guid(),
|
||||
libraryId ?? _faker.Random.Guid(),
|
||||
mediaItemId ?? _faker.Random.Guid(),
|
||||
resolvedMediaKind,
|
||||
lastPosition ?? _mediaPositionDtoFixture.Create(kind: ResolveDefaultPositionKind(resolvedMediaKind)),
|
||||
lastProgressFraction ?? _faker.Random.Double(0, 1),
|
||||
lastConsumedOnUtc ?? DateTime.UtcNow.AddHours(-_faker.Random.Int(1, 720)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="ResumePointDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ResumePointDto"/> instances.</returns>
|
||||
public List<ResumePointDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the default kind of position used by a media kind.
|
||||
/// </summary>
|
||||
/// <param name="mediaKind">The kind of media.</param>
|
||||
/// <returns>The position kind that a resume point of the media kind uses.</returns>
|
||||
private static MediaPositionKind ResolveDefaultPositionKind(MediaKind mediaKind)
|
||||
{
|
||||
return mediaKind == MediaKind.Book ? MediaPositionKind.Location : MediaPositionKind.TimeOffset;
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.MediaConsumption;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="StatisticsPageDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class StatisticsPageDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="StatisticsPageDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="title">Optional localized title of the page.</param>
|
||||
/// <param name="isAdmin">Optional value indicating whether the current user is an administrator.</param>
|
||||
/// <param name="currentUserId">Optional Id of the current user.</param>
|
||||
/// <param name="culture">Optional culture of the page.</param>
|
||||
/// <param name="getStatisticsUrl">Optional route that returns the statistics of the selected user.</param>
|
||||
/// <param name="getAllUsersStatisticsUrl">Optional route that returns the statistics of every user.</param>
|
||||
/// <param name="getRecentlyConsumedUrl">Optional route that returns the recently consumed media items.</param>
|
||||
/// <param name="getMostConsumedUrl">Optional route that returns the most consumed media items.</param>
|
||||
/// <param name="getTagConsumptionUrl">Optional route that returns the tag consumption.</param>
|
||||
/// <param name="getGenreConsumptionUrl">Optional route that returns the genre consumption.</param>
|
||||
/// <param name="getLibrariesUrl">Optional route that returns the libraries available for the library filter.</param>
|
||||
/// <param name="getUsersUrl">Optional route that returns the users available for the administrator user selector.</param>
|
||||
/// <param name="deleteConsumptionItemHistoryUrl">Optional route that deletes every consumption record of a media item.</param>
|
||||
/// <param name="clearConsumptionHistoryUrl">Optional route that deletes the consumption history.</param>
|
||||
/// <param name="clearResumePointsUrl">Optional route that deletes the resume points.</param>
|
||||
/// <param name="includeCurrentUserId">Whether the current user Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="StatisticsPageDto"/> instance.</returns>
|
||||
public StatisticsPageDto Create(
|
||||
string? title = null,
|
||||
bool? isAdmin = null,
|
||||
Guid? currentUserId = null,
|
||||
string? culture = null,
|
||||
string? getStatisticsUrl = null,
|
||||
string? getAllUsersStatisticsUrl = null,
|
||||
string? getRecentlyConsumedUrl = null,
|
||||
string? getMostConsumedUrl = null,
|
||||
string? getTagConsumptionUrl = null,
|
||||
string? getGenreConsumptionUrl = null,
|
||||
string? getLibrariesUrl = null,
|
||||
string? getUsersUrl = null,
|
||||
string? deleteConsumptionItemHistoryUrl = null,
|
||||
string? clearConsumptionHistoryUrl = null,
|
||||
string? clearResumePointsUrl = null,
|
||||
bool includeCurrentUserId = true)
|
||||
{
|
||||
return new StatisticsPageDto(
|
||||
Title: title ?? _faker.Lorem.Sentence(),
|
||||
IsAdmin: isAdmin ?? _faker.Random.Bool(),
|
||||
CurrentUserId: includeCurrentUserId ? (currentUserId ?? _faker.Random.Guid()) : null,
|
||||
Culture: culture ?? _faker.PickRandom("en-US", "de-DE", "fr-FR"),
|
||||
GetStatisticsUrl: getStatisticsUrl ?? _faker.Internet.Url(),
|
||||
GetAllUsersStatisticsUrl: getAllUsersStatisticsUrl ?? _faker.Internet.Url(),
|
||||
GetRecentlyConsumedUrl: getRecentlyConsumedUrl ?? _faker.Internet.Url(),
|
||||
GetMostConsumedUrl: getMostConsumedUrl ?? _faker.Internet.Url(),
|
||||
GetTagConsumptionUrl: getTagConsumptionUrl ?? _faker.Internet.Url(),
|
||||
GetGenreConsumptionUrl: getGenreConsumptionUrl ?? _faker.Internet.Url(),
|
||||
GetLibrariesUrl: getLibrariesUrl ?? _faker.Internet.Url(),
|
||||
GetUsersUrl: getUsersUrl ?? _faker.Internet.Url(),
|
||||
DeleteConsumptionItemHistoryUrl: deleteConsumptionItemHistoryUrl ?? _faker.Internet.Url(),
|
||||
ClearConsumptionHistoryUrl: clearConsumptionHistoryUrl ?? _faker.Internet.Url(),
|
||||
ClearResumePointsUrl: clearResumePointsUrl ?? _faker.Internet.Url()
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="StatisticsPageDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="StatisticsPageDto"/> instances.</returns>
|
||||
public List<StatisticsPageDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.MediaConsumption;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="TagConsumptionDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class TagConsumptionDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="TagConsumptionDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="name">Optional lowercase name of the tag.</param>
|
||||
/// <param name="consumedItemCount">Optional number of distinct consumed media items that carry the tag.</param>
|
||||
/// <param name="consumedDurationInSeconds">Optional consumed duration, in seconds.</param>
|
||||
/// <returns>A configured <see cref="TagConsumptionDto"/> instance.</returns>
|
||||
public TagConsumptionDto Create(
|
||||
string? name = null,
|
||||
int? consumedItemCount = null,
|
||||
double? consumedDurationInSeconds = null)
|
||||
{
|
||||
return new TagConsumptionDto(
|
||||
Name: name ?? _faker.Lorem.Word().ToLowerInvariant(),
|
||||
ConsumedItemCount: consumedItemCount ?? _faker.Random.Int(0, 1000),
|
||||
ConsumedDurationInSeconds: consumedDurationInSeconds ?? _faker.Random.Double(0, 100000)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="TagConsumptionDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="TagConsumptionDto"/> instances.</returns>
|
||||
public List<TagConsumptionDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.DTO.MediaContributors;
|
||||
using Lumina.Presentation.Web.Common.Enums.MediaContributors;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.MediaContributors;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaContributorDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaContributorDtoFixture
|
||||
{
|
||||
private readonly MediaContributorNameDtoFixture _mediaContributorNameDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="MediaContributorDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="displayName">Optional. The name by which the contributor is popularly known.</param>
|
||||
/// <param name="legalName">Optional. The legal name of the contributor.</param>
|
||||
/// <param name="role">Optional. The canonical role of the contributor.</param>
|
||||
/// <returns>A configured <see cref="MediaContributorDto"/> instance.</returns>
|
||||
public MediaContributorDto Create(
|
||||
string? displayName = null,
|
||||
string? legalName = null,
|
||||
MediaContributorRole? role = null)
|
||||
{
|
||||
return new MediaContributorDto
|
||||
{
|
||||
Name = _mediaContributorNameDtoFixture.Create(displayName, legalName),
|
||||
Role = role ?? MediaContributorRole.Author
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MediaContributorDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaContributorDto"/> instances.</returns>
|
||||
public List<MediaContributorDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.MediaContributors;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.MediaContributors;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaContributorNameDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaContributorNameDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="MediaContributorNameDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="displayName">Optional. The name by which the contributor is popularly known.</param>
|
||||
/// <param name="legalName">Optional. The legal name of the contributor.</param>
|
||||
/// <returns>A configured <see cref="MediaContributorNameDto"/> instance.</returns>
|
||||
public MediaContributorNameDto Create(
|
||||
string? displayName = null,
|
||||
string? legalName = null)
|
||||
{
|
||||
return new MediaContributorNameDto
|
||||
{
|
||||
DisplayName = displayName ?? _faker.Name.FullName(),
|
||||
LegalName = legalName ?? _faker.Name.FullName()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MediaContributorNameDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaContributorNameDto"/> instances.</returns>
|
||||
public List<MediaContributorNameDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.MediaContributors;
|
||||
using Lumina.Presentation.Web.Common.Enums.MediaContributors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.MediaContributors;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaContributorReferenceDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaContributorReferenceDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="MediaContributorReferenceDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="contributorId">Optional. The unique identifier of the media contributor.</param>
|
||||
/// <param name="role">Optional. The role the contributor played.</param>
|
||||
/// <param name="includeRole">Whether the role should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="MediaContributorReferenceDto"/> instance.</returns>
|
||||
public MediaContributorReferenceDto Create(
|
||||
Guid? contributorId = null,
|
||||
MediaContributorRole? role = null,
|
||||
bool includeRole = true)
|
||||
{
|
||||
return new MediaContributorReferenceDto
|
||||
{
|
||||
ContributorId = contributorId ?? _faker.Random.Guid(),
|
||||
Role = includeRole ? (role ?? _faker.PickRandom<MediaContributorRole>()) : null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MediaContributorReferenceDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaContributorReferenceDto"/> instances.</returns>
|
||||
public List<MediaContributorReferenceDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Playlists;
|
||||
using Lumina.Presentation.Web.Common.Enums.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistDetailsDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistDetailsDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="PlaylistDetailsDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional Id of the playlist.</param>
|
||||
/// <param name="name">Optional name of the playlist.</param>
|
||||
/// <param name="description">Optional description of the playlist.</param>
|
||||
/// <param name="type">Optional kind of media the playlist holds.</param>
|
||||
/// <param name="updatedOnUtc">Optional date and time when the playlist was last updated.</param>
|
||||
/// <param name="includeDescription">Whether the description should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the last update date should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="PlaylistDetailsDto"/> instance.</returns>
|
||||
public PlaylistDetailsDto Create(
|
||||
Guid? id = null,
|
||||
string? name = null,
|
||||
string? description = null,
|
||||
PlaylistType? type = null,
|
||||
DateTime? updatedOnUtc = null,
|
||||
bool includeDescription = true,
|
||||
bool includeUpdatedOnUtc = true)
|
||||
{
|
||||
DateTime resolvedUpdatedOnUtc = DateTime.SpecifyKind(updatedOnUtc ?? DateTime.UtcNow.AddHours(-_faker.Random.Int(1, 24)), DateTimeKind.Utc);
|
||||
return new PlaylistDetailsDto(
|
||||
Id: id ?? _faker.Random.Guid(),
|
||||
Name: name ?? _faker.Lorem.Sentence(3),
|
||||
Description: includeDescription ? (description ?? _faker.Lorem.Sentence(5)) : null,
|
||||
Type: type ?? PlaylistType.Music,
|
||||
UpdatedOnUtc: includeUpdatedOnUtc ? resolvedUpdatedOnUtc : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="PlaylistDetailsDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistDetailsDto"/> instances.</returns>
|
||||
public List<PlaylistDetailsDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.DTO.Playlists;
|
||||
using Lumina.Presentation.Web.Common.Enums.Playlists;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly PlaylistEntryDtoFixture _playlistEntryDtoFixture = new();
|
||||
private readonly PaginatedDtoFixture<PlaylistEntryDto> _paginatedDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="PlaylistDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional Id of the playlist.</param>
|
||||
/// <param name="name">Optional name of the playlist.</param>
|
||||
/// <param name="description">Optional description of the playlist.</param>
|
||||
/// <param name="type">Optional kind of media the playlist holds.</param>
|
||||
/// <param name="entries">Optional page of ordered entries of the playlist.</param>
|
||||
/// <param name="createdOnUtc">Optional date and time when the playlist was created.</param>
|
||||
/// <param name="updatedOnUtc">Optional date and time when the playlist was last updated.</param>
|
||||
/// <param name="includeDescription">Whether the description should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the last update date should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="PlaylistDto"/> instance.</returns>
|
||||
public PlaylistDto Create(
|
||||
Guid? id = null,
|
||||
string? name = null,
|
||||
string? description = null,
|
||||
PlaylistType? type = null,
|
||||
PaginatedDto<PlaylistEntryDto>? entries = null,
|
||||
DateTime? createdOnUtc = null,
|
||||
DateTime? updatedOnUtc = null,
|
||||
bool includeDescription = true,
|
||||
bool includeUpdatedOnUtc = true)
|
||||
{
|
||||
DateTime resolvedCreatedOnUtc = DateTime.SpecifyKind(createdOnUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)), DateTimeKind.Utc);
|
||||
DateTime resolvedUpdatedOnUtc = DateTime.SpecifyKind(updatedOnUtc ?? resolvedCreatedOnUtc.AddHours(_faker.Random.Int(1, 24)), DateTimeKind.Utc);
|
||||
return new PlaylistDto(
|
||||
Id: id ?? _faker.Random.Guid(),
|
||||
Name: name ?? _faker.Lorem.Sentence(3),
|
||||
Description: includeDescription ? (description ?? _faker.Lorem.Sentence(5)) : null,
|
||||
Type: type ?? PlaylistType.Music,
|
||||
Entries: entries ?? _paginatedDtoFixture.Create(data: _playlistEntryDtoFixture.CreateMany(_faker.Random.Int(0, 5))),
|
||||
CreatedOnUtc: resolvedCreatedOnUtc,
|
||||
UpdatedOnUtc: includeUpdatedOnUtc ? resolvedUpdatedOnUtc : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="PlaylistDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistDto"/> instances.</returns>
|
||||
public List<PlaylistDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistEntriesAddedDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistEntriesAddedDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="PlaylistEntriesAddedDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="playlistId">Optional Id of the playlist the entries were added to.</param>
|
||||
/// <param name="addedCount">Optional number of entries that were appended.</param>
|
||||
/// <param name="updatedOnUtc">Optional date and time when the playlist was last updated.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the last update date should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="PlaylistEntriesAddedDto"/> instance.</returns>
|
||||
public PlaylistEntriesAddedDto Create(
|
||||
Guid? playlistId = null,
|
||||
int? addedCount = null,
|
||||
DateTime? updatedOnUtc = null,
|
||||
bool includeUpdatedOnUtc = true)
|
||||
{
|
||||
DateTime resolvedUpdatedOnUtc = DateTime.SpecifyKind(updatedOnUtc ?? DateTime.UtcNow.AddHours(-_faker.Random.Int(1, 24)), DateTimeKind.Utc);
|
||||
return new PlaylistEntriesAddedDto(
|
||||
PlaylistId: playlistId ?? _faker.Random.Guid(),
|
||||
AddedCount: addedCount ?? _faker.Random.Int(0, 1_000),
|
||||
UpdatedOnUtc: includeUpdatedOnUtc ? resolvedUpdatedOnUtc : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="PlaylistEntriesAddedDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistEntriesAddedDto"/> instances.</returns>
|
||||
public List<PlaylistEntriesAddedDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistEntryAddedDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistEntryAddedDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly PlaylistEntryDtoFixture _playlistEntryDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="PlaylistEntryAddedDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="playlistId">Optional Id of the playlist the entry was added to.</param>
|
||||
/// <param name="entry">Optional added entry.</param>
|
||||
/// <param name="updatedOnUtc">Optional date and time when the playlist was last updated.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the last update date should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="PlaylistEntryAddedDto"/> instance.</returns>
|
||||
public PlaylistEntryAddedDto Create(
|
||||
Guid? playlistId = null,
|
||||
PlaylistEntryDto? entry = null,
|
||||
DateTime? updatedOnUtc = null,
|
||||
bool includeUpdatedOnUtc = true)
|
||||
{
|
||||
DateTime resolvedUpdatedOnUtc = DateTime.SpecifyKind(updatedOnUtc ?? DateTime.UtcNow.AddHours(-_faker.Random.Int(1, 24)), DateTimeKind.Utc);
|
||||
return new PlaylistEntryAddedDto(
|
||||
PlaylistId: playlistId ?? _faker.Random.Guid(),
|
||||
Entry: entry ?? _playlistEntryDtoFixture.Create(),
|
||||
UpdatedOnUtc: includeUpdatedOnUtc ? resolvedUpdatedOnUtc : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="PlaylistEntryAddedDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistEntryAddedDto"/> instances.</returns>
|
||||
public List<PlaylistEntryAddedDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Playlists;
|
||||
using Lumina.Presentation.Web.Common.Enums.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistEntryDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistEntryDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="PlaylistEntryDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional Id of the entry.</param>
|
||||
/// <param name="mediaItemId">Optional Id of the media item referenced by the entry.</param>
|
||||
/// <param name="mediaItemType">Optional kind of media item referenced by the entry.</param>
|
||||
/// <param name="position">Optional zero based position of the entry in the playlist.</param>
|
||||
/// <param name="libraryId">Optional Id of the media library that contains the media item.</param>
|
||||
/// <param name="collectionId">Optional Id of the collection that contains the media item.</param>
|
||||
/// <param name="creatorId">Optional Id of the creator of the media item.</param>
|
||||
/// <param name="mediaItemTitle">Optional title of the media item.</param>
|
||||
/// <param name="collectionTitle">Optional title of the collection that contains the media item.</param>
|
||||
/// <param name="creatorName">Optional name of the creator of the media item.</param>
|
||||
/// <param name="durationInSeconds">Optional duration of the media item in seconds.</param>
|
||||
/// <param name="coverPath">Optional path of the cover art of the collection.</param>
|
||||
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="PlaylistEntryDto"/> instance.</returns>
|
||||
public PlaylistEntryDto Create(
|
||||
Guid? id = null,
|
||||
Guid? mediaItemId = null,
|
||||
PlaylistMediaItemType? mediaItemType = null,
|
||||
int? position = null,
|
||||
Guid? libraryId = null,
|
||||
Guid? collectionId = null,
|
||||
Guid? creatorId = null,
|
||||
string? mediaItemTitle = null,
|
||||
string? collectionTitle = null,
|
||||
string? creatorName = null,
|
||||
int? durationInSeconds = null,
|
||||
string? coverPath = null,
|
||||
bool includeCoverPath = true)
|
||||
{
|
||||
return new PlaylistEntryDto(
|
||||
Id: id ?? _faker.Random.Guid(),
|
||||
MediaItemId: mediaItemId ?? _faker.Random.Guid(),
|
||||
MediaItemType: mediaItemType ?? _faker.PickRandom(PlaylistMediaItemType.MusicTrack, PlaylistMediaItemType.VideoFile),
|
||||
Position: position ?? _faker.Random.Int(0, 1000),
|
||||
LibraryId: libraryId ?? _faker.Random.Guid(),
|
||||
CollectionId: collectionId ?? _faker.Random.Guid(),
|
||||
CreatorId: creatorId ?? _faker.Random.Guid(),
|
||||
MediaItemTitle: mediaItemTitle ?? _faker.Lorem.Sentence(3),
|
||||
CollectionTitle: collectionTitle ?? _faker.Lorem.Sentence(2),
|
||||
CreatorName: creatorName ?? _faker.Name.FullName(),
|
||||
DurationInSeconds: durationInSeconds ?? _faker.Random.Int(0, 36000),
|
||||
CoverPath: includeCoverPath ? (coverPath ?? $"/artwork/{_faker.Random.Guid()}/cover.jpg") : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="PlaylistEntryDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistEntryDto"/> instances.</returns>
|
||||
public List<PlaylistEntryDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistEntryMovedDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistEntryMovedDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="PlaylistEntryMovedDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="playlistId">Optional Id of the playlist whose entry was moved.</param>
|
||||
/// <param name="entryId">Optional Id of the moved entry.</param>
|
||||
/// <param name="position">Optional new zero based position of the entry.</param>
|
||||
/// <param name="updatedOnUtc">Optional date and time when the playlist was last updated.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the last update date should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="PlaylistEntryMovedDto"/> instance.</returns>
|
||||
public PlaylistEntryMovedDto Create(
|
||||
Guid? playlistId = null,
|
||||
Guid? entryId = null,
|
||||
int? position = null,
|
||||
DateTime? updatedOnUtc = null,
|
||||
bool includeUpdatedOnUtc = true)
|
||||
{
|
||||
DateTime resolvedUpdatedOnUtc = DateTime.SpecifyKind(updatedOnUtc ?? DateTime.UtcNow.AddHours(-_faker.Random.Int(1, 24)), DateTimeKind.Utc);
|
||||
return new PlaylistEntryMovedDto(
|
||||
PlaylistId: playlistId ?? _faker.Random.Guid(),
|
||||
EntryId: entryId ?? _faker.Random.Guid(),
|
||||
Position: position ?? _faker.Random.Int(0, 1_000),
|
||||
UpdatedOnUtc: includeUpdatedOnUtc ? resolvedUpdatedOnUtc : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="PlaylistEntryMovedDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistEntryMovedDto"/> instances.</returns>
|
||||
public List<PlaylistEntryMovedDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Playlists;
|
||||
using Lumina.Presentation.Web.Common.Enums.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistSummaryDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistSummaryDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="PlaylistSummaryDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional Id of the playlist.</param>
|
||||
/// <param name="name">Optional name of the playlist.</param>
|
||||
/// <param name="description">Optional description of the playlist.</param>
|
||||
/// <param name="type">Optional kind of media the playlist holds.</param>
|
||||
/// <param name="entryCount">Optional number of entries of the playlist.</param>
|
||||
/// <param name="createdOnUtc">Optional date and time when the playlist was created.</param>
|
||||
/// <param name="updatedOnUtc">Optional date and time when the playlist was last updated.</param>
|
||||
/// <param name="includeDescription">Whether the description should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the last update date should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="PlaylistSummaryDto"/> instance.</returns>
|
||||
public PlaylistSummaryDto Create(
|
||||
Guid? id = null,
|
||||
string? name = null,
|
||||
string? description = null,
|
||||
PlaylistType? type = null,
|
||||
int? entryCount = null,
|
||||
DateTime? createdOnUtc = null,
|
||||
DateTime? updatedOnUtc = null,
|
||||
bool includeDescription = true,
|
||||
bool includeUpdatedOnUtc = true)
|
||||
{
|
||||
DateTime resolvedCreatedOnUtc = DateTime.SpecifyKind(createdOnUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)), DateTimeKind.Utc);
|
||||
DateTime resolvedUpdatedOnUtc = DateTime.SpecifyKind(updatedOnUtc ?? resolvedCreatedOnUtc.AddHours(_faker.Random.Int(1, 24)), DateTimeKind.Utc);
|
||||
return new PlaylistSummaryDto(
|
||||
Id: id ?? _faker.Random.Guid(),
|
||||
Name: name ?? _faker.Lorem.Sentence(3),
|
||||
Description: includeDescription ? (description ?? _faker.Lorem.Sentence(5)) : null,
|
||||
Type: type ?? PlaylistType.Music,
|
||||
EntryCount: entryCount ?? _faker.Random.Int(0, 1_000),
|
||||
CreatedOnUtc: resolvedCreatedOnUtc,
|
||||
UpdatedOnUtc: includeUpdatedOnUtc ? resolvedUpdatedOnUtc : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="PlaylistSummaryDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistSummaryDto"/> instances.</returns>
|
||||
public List<PlaylistSummaryDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryArtworkProviderDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryArtworkProviderDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="LibraryArtworkProviderDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="pluginId">Optional unique identifier of the plugin providing the artwork.</param>
|
||||
/// <param name="name">Optional display name of the artwork provider.</param>
|
||||
/// <param name="isEnabled">Whether the artwork provider is enabled for the media library or not.</param>
|
||||
/// <param name="rank">Optional rank of the artwork provider, determining the order in which providers are tried.</param>
|
||||
/// <returns>A configured <see cref="LibraryArtworkProviderDto"/> instance.</returns>
|
||||
public LibraryArtworkProviderDto Create(
|
||||
Guid? pluginId = null,
|
||||
string? name = null,
|
||||
bool? isEnabled = null,
|
||||
int? rank = null)
|
||||
{
|
||||
return new LibraryArtworkProviderDto
|
||||
{
|
||||
PluginId = pluginId ?? Guid.NewGuid(),
|
||||
Name = name ?? _faker.Company.CompanyName(),
|
||||
IsEnabled = isEnabled ?? _faker.Random.Bool(),
|
||||
Rank = rank ?? _faker.Random.Int(0, 100)
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="LibraryArtworkProviderDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="LibraryArtworkProviderDto"/> instances.</returns>
|
||||
public List<LibraryArtworkProviderDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.DTO.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryBookReaderDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryBookReaderDtoFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="LibraryBookReaderDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="pluginId">Optional unique identifier of the plugin providing the book reader.</param>
|
||||
/// <param name="name">Optional display name of the book reader.</param>
|
||||
/// <param name="supportedExtensions">Optional file extensions supported by the book reader.</param>
|
||||
/// <param name="isEnabled">Optional value indicating whether the book reader is enabled for the media library.</param>
|
||||
/// <returns>A configured <see cref="LibraryBookReaderDto"/> instance.</returns>
|
||||
public LibraryBookReaderDto Create(
|
||||
Guid? pluginId = null,
|
||||
string? name = null,
|
||||
List<string>? supportedExtensions = null,
|
||||
bool? isEnabled = null)
|
||||
{
|
||||
return new LibraryBookReaderDto
|
||||
{
|
||||
PluginId = pluginId ?? Guid.NewGuid(),
|
||||
Name = name ?? $"Reader {Guid.NewGuid():N}",
|
||||
SupportedExtensions = supportedExtensions ?? [".epub", ".pdf"],
|
||||
IsEnabled = isEnabled ?? true
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="LibraryBookReaderDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="LibraryBookReaderDto"/> instances.</returns>
|
||||
public List<LibraryBookReaderDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryMetadataProviderDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryMetadataProviderDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="LibraryMetadataProviderDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="pluginId">Optional unique identifier of the plugin providing the metadata.</param>
|
||||
/// <param name="name">Optional display name of the metadata provider.</param>
|
||||
/// <param name="isEnabled">Whether the metadata provider is enabled for the media library or not.</param>
|
||||
/// <param name="rank">Optional rank of the metadata provider, determining the order in which providers are tried.</param>
|
||||
/// <returns>A configured <see cref="LibraryMetadataProviderDto"/> instance.</returns>
|
||||
public LibraryMetadataProviderDto Create(
|
||||
Guid? pluginId = null,
|
||||
string? name = null,
|
||||
bool? isEnabled = null,
|
||||
int? rank = null)
|
||||
{
|
||||
return new LibraryMetadataProviderDto
|
||||
{
|
||||
PluginId = pluginId ?? Guid.NewGuid(),
|
||||
Name = name ?? _faker.Company.CompanyName(),
|
||||
IsEnabled = isEnabled ?? _faker.Random.Bool(),
|
||||
Rank = rank ?? _faker.Random.Int(0, 100)
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="LibraryMetadataProviderDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="LibraryMetadataProviderDto"/> instances.</returns>
|
||||
public List<LibraryMetadataProviderDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Plugins;
|
||||
using Lumina.Presentation.Web.Common.Enums.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PluginDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PluginDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="PluginDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional identifier of the plugin.</param>
|
||||
/// <param name="name">Optional name of the plugin.</param>
|
||||
/// <param name="author">Optional author of the plugin.</param>
|
||||
/// <param name="version">Optional version of the plugin.</param>
|
||||
/// <param name="loadStatus">Optional load status of the plugin.</param>
|
||||
/// <returns>A configured <see cref="PluginDto"/> instance.</returns>
|
||||
public PluginDto Create(Guid? id = null, string? name = null, string? author = null, string? version = null, PluginLoadStatus? loadStatus = null)
|
||||
{
|
||||
return new PluginDto
|
||||
{
|
||||
Id = id ?? Guid.NewGuid(),
|
||||
Name = name ?? _faker.Hacker.Noun(),
|
||||
Author = author ?? _faker.Name.FullName(),
|
||||
Version = version ?? _faker.System.Semver(),
|
||||
Description = _faker.Lorem.Sentence(),
|
||||
LoadStatus = loadStatus ?? PluginLoadStatus.Loaded,
|
||||
LoadError = null,
|
||||
Settings = null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="PluginDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PluginDto"/> instances.</returns>
|
||||
public List<PluginDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Plugins;
|
||||
using Lumina.Presentation.Web.Common.Enums.Plugins;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PluginSettingDescriptorDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PluginSettingDescriptorDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PluginSettingDescriptorDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="key">Optional. The key of the setting.</param>
|
||||
/// <param name="label">Optional. The display label of the setting.</param>
|
||||
/// <param name="type">Optional. The type of the setting.</param>
|
||||
/// <param name="defaultValue">Optional. The default value of the setting.</param>
|
||||
/// <param name="allowedValues">Optional. The list of allowed values of the setting.</param>
|
||||
/// <returns>The created <see cref="PluginSettingDescriptorDto"/>.</returns>
|
||||
public PluginSettingDescriptorDto Create(
|
||||
string? key = null,
|
||||
string? label = null,
|
||||
PluginSettingType? type = null,
|
||||
string? defaultValue = null,
|
||||
IReadOnlyList<string>? allowedValues = null)
|
||||
{
|
||||
return new PluginSettingDescriptorDto
|
||||
{
|
||||
Key = key ?? _faker.Random.String2(4, 32),
|
||||
Label = label ?? _faker.Commerce.ProductName(),
|
||||
Type = type ?? _faker.Random.Enum<PluginSettingType>(),
|
||||
DefaultValue = defaultValue,
|
||||
AllowedValues = allowedValues
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PluginSettingDescriptorDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<PluginSettingDescriptorDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PluginSettingsDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PluginSettingsDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly PluginSettingDescriptorDtoFixture _pluginSettingDescriptorDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="PluginSettingsDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="pluginId">Optional unique identifier of the plugin.</param>
|
||||
/// <param name="includeSettings">Whether the current settings values should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeSchema">Whether the settings schema should be included, or forced to an empty collection.</param>
|
||||
/// <returns>A configured <see cref="PluginSettingsDto"/> instance.</returns>
|
||||
public PluginSettingsDto Create(
|
||||
Guid? pluginId = null,
|
||||
bool includeSettings = true,
|
||||
bool includeSchema = true)
|
||||
{
|
||||
string settingKey = _faker.Lorem.Word();
|
||||
return new PluginSettingsDto
|
||||
{
|
||||
PluginId = pluginId ?? Guid.NewGuid(),
|
||||
Schema = includeSchema
|
||||
? [_pluginSettingDescriptorDtoFixture.Create(key: settingKey)]
|
||||
: [],
|
||||
Settings = includeSettings
|
||||
? new Dictionary<string, string> { [settingKey] = _faker.Lorem.Word() }
|
||||
: null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="PluginSettingsDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PluginSettingsDto"/> instances.</returns>
|
||||
public List<PluginSettingsDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.DTO.Reading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ReadingAvailabilityDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReadingAvailabilityDtoFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ReadingAvailabilityDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="bookId">Optional identifier of the book whose reading availability is reported.</param>
|
||||
/// <param name="libraryId">Optional identifier of the media library the book belongs to.</param>
|
||||
/// <param name="isAvailable">Optional value indicating whether the book can be opened for reading.</param>
|
||||
/// <param name="errorCode">Optional code of the error preventing the book from being read, when it cannot be read.</param>
|
||||
/// <returns>A configured <see cref="ReadingAvailabilityDto"/> instance.</returns>
|
||||
public ReadingAvailabilityDto Create(
|
||||
Guid? bookId = null,
|
||||
Guid? libraryId = null,
|
||||
bool? isAvailable = null,
|
||||
string? errorCode = null)
|
||||
{
|
||||
return new ReadingAvailabilityDto
|
||||
{
|
||||
BookId = bookId ?? Guid.NewGuid(),
|
||||
LibraryId = libraryId ?? Guid.NewGuid(),
|
||||
IsAvailable = isAvailable ?? true,
|
||||
ErrorCode = errorCode
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="ReadingAvailabilityDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ReadingAvailabilityDto"/> instances.</returns>
|
||||
public List<ReadingAvailabilityDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.DTO.Reading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ReadingManifestDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReadingManifestDtoFixture
|
||||
{
|
||||
private readonly ReadingTocEntryDtoFixture _readingTocEntryDtoFixture = new();
|
||||
private readonly ReadingSpineItemDtoFixture _readingSpineItemDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ReadingManifestDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="title">Optional title of the book.</param>
|
||||
/// <param name="author">Optional author of the book.</param>
|
||||
/// <param name="coverResourceKey">Optional resource key of the cover image of the book.</param>
|
||||
/// <param name="tableOfContents">Optional hierarchical table of contents of the book.</param>
|
||||
/// <param name="spine">Optional ordered spine of the reading sections of the book.</param>
|
||||
/// <param name="resourceKeys">Optional resource keys of the resources of the book.</param>
|
||||
/// <param name="hasTextContent">Optional value indicating whether the book has extractable text content.</param>
|
||||
/// <returns>A configured <see cref="ReadingManifestDto"/> instance.</returns>
|
||||
public ReadingManifestDto Create(
|
||||
string? title = null,
|
||||
string? author = null,
|
||||
string? coverResourceKey = null,
|
||||
List<ReadingTocEntryDto>? tableOfContents = null,
|
||||
List<ReadingSpineItemDto>? spine = null,
|
||||
List<string>? resourceKeys = null,
|
||||
bool? hasTextContent = null)
|
||||
{
|
||||
return new ReadingManifestDto
|
||||
{
|
||||
Title = title ?? $"Book {Guid.NewGuid():N}",
|
||||
Author = author,
|
||||
CoverResourceKey = coverResourceKey,
|
||||
TableOfContents = tableOfContents ?? [.. _readingTocEntryDtoFixture.CreateMany(2)],
|
||||
Spine = spine ?? [.. _readingSpineItemDtoFixture.CreateMany(2)],
|
||||
ResourceKeys = resourceKeys ?? [.. Enumerable.Range(0, 2).Select(_ => $"resource-{Guid.NewGuid():N}")],
|
||||
HasTextContent = hasTextContent ?? true
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="ReadingManifestDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ReadingManifestDto"/> instances.</returns>
|
||||
public List<ReadingManifestDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.DTO.Reading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ReadingSectionDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReadingSectionDtoFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ReadingSectionDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="locationRef">Optional opaque location reference of the reading section.</param>
|
||||
/// <param name="title">Optional title of the reading section.</param>
|
||||
/// <param name="contentHtml">Optional sanitized HTML content of the reading section.</param>
|
||||
/// <returns>A configured <see cref="ReadingSectionDto"/> instance.</returns>
|
||||
public ReadingSectionDto Create(
|
||||
string? locationRef = null,
|
||||
string? title = null,
|
||||
string? contentHtml = null)
|
||||
{
|
||||
return new ReadingSectionDto
|
||||
{
|
||||
LocationRef = locationRef ?? $"section-{Guid.NewGuid():N}",
|
||||
Title = title,
|
||||
ContentHtml = contentHtml ?? "<section><p>Content</p></section>"
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="ReadingSectionDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ReadingSectionDto"/> instances.</returns>
|
||||
public List<ReadingSectionDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.DTO.Reading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ReadingSpineItemDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReadingSpineItemDtoFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ReadingSpineItemDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="locationRef">Optional opaque location reference of the reading section.</param>
|
||||
/// <param name="title">Optional title of the reading section.</param>
|
||||
/// <returns>A configured <see cref="ReadingSpineItemDto"/> instance.</returns>
|
||||
public ReadingSpineItemDto Create(
|
||||
string? locationRef = null,
|
||||
string? title = null)
|
||||
{
|
||||
return new ReadingSpineItemDto
|
||||
{
|
||||
LocationRef = locationRef ?? $"section-{Guid.NewGuid():N}",
|
||||
Title = title
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="ReadingSpineItemDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ReadingSpineItemDto"/> instances.</returns>
|
||||
public List<ReadingSpineItemDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.DTO.Reading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ReadingTocEntryDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReadingTocEntryDtoFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ReadingTocEntryDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="label">Optional label of the table of contents entry.</param>
|
||||
/// <param name="locationRef">Optional opaque location reference of the reading section the entry points to.</param>
|
||||
/// <param name="children">Optional child entries of the table of contents entry.</param>
|
||||
/// <returns>A configured <see cref="ReadingTocEntryDto"/> instance.</returns>
|
||||
public ReadingTocEntryDto Create(
|
||||
string? label = null,
|
||||
string? locationRef = null,
|
||||
List<ReadingTocEntryDto>? children = null)
|
||||
{
|
||||
return new ReadingTocEntryDto
|
||||
{
|
||||
Label = label ?? $"Chapter {Guid.NewGuid():N}",
|
||||
LocationRef = locationRef ?? $"section-{Guid.NewGuid():N}",
|
||||
Children = children ?? []
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="ReadingTocEntryDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ReadingTocEntryDto"/> instances.</returns>
|
||||
public List<ReadingTocEntryDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Scheduling;
|
||||
using Lumina.Presentation.Web.Common.Enums.Scheduling;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Scheduling;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ScheduledJobDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ScheduledJobDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ScheduledJobDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional unique identifier of the scheduled job.</param>
|
||||
/// <param name="name">Optional name of the scheduled job.</param>
|
||||
/// <param name="taskType">Optional type of the task executed by the scheduled job.</param>
|
||||
/// <param name="scheduleType">Optional type of the schedule of the scheduled job.</param>
|
||||
/// <param name="intervalMinutes">Optional interval in minutes of the schedule of the scheduled job.</param>
|
||||
/// <param name="hour">Optional hour of the schedule of the scheduled job.</param>
|
||||
/// <param name="minute">Optional minute of the schedule of the scheduled job.</param>
|
||||
/// <param name="status">Optional status of the scheduled job.</param>
|
||||
/// <param name="lastStartedOnUtc">Optional date and time when the task of the scheduled job last started its execution.</param>
|
||||
/// <param name="lastCompletedOnUtc">Optional date and time when the task of the scheduled job last completed its execution.</param>
|
||||
/// <returns>A configured <see cref="ScheduledJobDto"/> instance.</returns>
|
||||
public ScheduledJobDto Create(
|
||||
Guid? id = null,
|
||||
string? name = null,
|
||||
ScheduledTaskType? taskType = null,
|
||||
ScheduleType? scheduleType = null,
|
||||
int? intervalMinutes = null,
|
||||
int? hour = null,
|
||||
int? minute = null,
|
||||
ScheduledJobStatus? status = null,
|
||||
DateTime? lastStartedOnUtc = null,
|
||||
DateTime? lastCompletedOnUtc = null)
|
||||
{
|
||||
ScheduleType resolvedScheduleType = scheduleType ?? _faker.PickRandom<ScheduleType>();
|
||||
DateTime? resolvedLastCompletedOnUtc = lastCompletedOnUtc ?? _faker.Date.Recent(10);
|
||||
return new ScheduledJobDto(
|
||||
Id: id ?? Guid.NewGuid(),
|
||||
Name: name ?? _faker.Name.JobTitle(),
|
||||
TaskType: taskType ?? _faker.PickRandom<ScheduledTaskType>(),
|
||||
ScheduleType: resolvedScheduleType,
|
||||
IntervalMinutes: intervalMinutes ?? (resolvedScheduleType == ScheduleType.WithIntervalInMinutes ? _faker.Random.Int(1, 1440) : null),
|
||||
Hour: hour ?? (resolvedScheduleType == ScheduleType.DailyAtHourAndMinute ? _faker.Random.Int(0, 23) : null),
|
||||
Minute: minute ?? (resolvedScheduleType == ScheduleType.DailyAtHourAndMinute ? _faker.Random.Int(0, 59) : null),
|
||||
Status: status ?? _faker.PickRandom<ScheduledJobStatus>(),
|
||||
LastStartedOnUtc: lastStartedOnUtc ?? _faker.Date.Recent(10),
|
||||
LastCompletedOnUtc: resolvedLastCompletedOnUtc);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="ScheduledJobDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ScheduledJobDto"/> instances.</returns>
|
||||
public List<ScheduledJobDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Scheduling;
|
||||
using Lumina.Presentation.Web.Common.Enums.Scheduling;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Scheduling;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ScheduledJobExecutionDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ScheduledJobExecutionDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ScheduledJobExecutionDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional unique identifier of the execution.</param>
|
||||
/// <param name="scheduledJobId">Optional unique identifier of the scheduled job whose task was executed.</param>
|
||||
/// <param name="taskType">Optional type of the task that was executed.</param>
|
||||
/// <param name="isCycleRun">Optional value indicating whether the execution was triggered by the execution cycle of the scheduled job.</param>
|
||||
/// <param name="startedOnUtc">Optional date and time when the execution started.</param>
|
||||
/// <param name="completedOnUtc">Optional date and time when the execution completed.</param>
|
||||
/// <returns>A configured <see cref="ScheduledJobExecutionDto"/> instance.</returns>
|
||||
public ScheduledJobExecutionDto Create(
|
||||
Guid? id = null,
|
||||
Guid? scheduledJobId = null,
|
||||
ScheduledTaskType? taskType = null,
|
||||
bool? isCycleRun = null,
|
||||
DateTime? startedOnUtc = null,
|
||||
DateTime? completedOnUtc = null)
|
||||
{
|
||||
DateTime resolvedStartedOnUtc = startedOnUtc ?? _faker.Date.Recent(10);
|
||||
return new ScheduledJobExecutionDto(
|
||||
Id: id ?? Guid.NewGuid(),
|
||||
ScheduledJobId: scheduledJobId ?? Guid.NewGuid(),
|
||||
TaskType: taskType ?? _faker.PickRandom<ScheduledTaskType>(),
|
||||
IsCycleRun: isCycleRun ?? _faker.Random.Bool(),
|
||||
StartedOnUtc: resolvedStartedOnUtc,
|
||||
CompletedOnUtc: completedOnUtc ?? _faker.Date.Soon(1, resolvedStartedOnUtc));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="ScheduledJobExecutionDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ScheduledJobExecutionDto"/> instances.</returns>
|
||||
public List<ScheduledJobExecutionDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Scheduling;
|
||||
using Lumina.Presentation.Web.Common.Enums.Scheduling;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Scheduling;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="SchedulerDisplayPreferencesDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class SchedulerDisplayPreferencesDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="SchedulerDisplayPreferencesDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="userId">Optional unique identifier of the user that owns the display preferences.</param>
|
||||
/// <param name="jobTypeFilter">Optional type of the scheduled job tasks whose executions are shown on the scheduler page.</param>
|
||||
/// <param name="displayTimeSpan">Optional time span, expressed in <paramref name="displayTimeUnit"/>, that the scheduler page shows.</param>
|
||||
/// <param name="displayTimeUnit">Optional unit in which the displayed time span of the scheduler page is expressed.</param>
|
||||
/// <returns>A configured <see cref="SchedulerDisplayPreferencesDto"/> instance.</returns>
|
||||
public SchedulerDisplayPreferencesDto Create(
|
||||
Guid? userId = null,
|
||||
ScheduledTaskType? jobTypeFilter = null,
|
||||
int? displayTimeSpan = null,
|
||||
SchedulerDisplayTimeUnit? displayTimeUnit = null)
|
||||
{
|
||||
return new SchedulerDisplayPreferencesDto(
|
||||
UserId: userId ?? Guid.NewGuid(),
|
||||
JobTypeFilter: jobTypeFilter,
|
||||
DisplayTimeSpan: displayTimeSpan ?? _faker.Random.Int(1, 30),
|
||||
DisplayTimeUnit: displayTimeUnit ?? _faker.PickRandom<SchedulerDisplayTimeUnit>());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="SchedulerDisplayPreferencesDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="SchedulerDisplayPreferencesDto"/> instances.</returns>
|
||||
public List<SchedulerDisplayPreferencesDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Themes;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Themes;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ThemeFileSystemBrowserConfigurationDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ThemeFileSystemBrowserConfigurationDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ThemeFileSystemBrowserConfigurationDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="clientBasePath">Optional base URL of the Web application.</param>
|
||||
/// <param name="path">Optional initial path displayed by the file system browser.</param>
|
||||
/// <param name="viewMode">Optional initial view mode of the file system browser.</param>
|
||||
/// <param name="iconSize">Optional initial icon size of the file system browser.</param>
|
||||
/// <returns>A configured <see cref="ThemeFileSystemBrowserConfigurationDto"/> instance.</returns>
|
||||
public ThemeFileSystemBrowserConfigurationDto Create(
|
||||
string? clientBasePath = null,
|
||||
string? path = null,
|
||||
string? viewMode = null,
|
||||
string? iconSize = null)
|
||||
{
|
||||
return new ThemeFileSystemBrowserConfigurationDto(
|
||||
ClientBasePath: clientBasePath ?? $"http://localhost:{_faker.Random.UShort()}/",
|
||||
Path: path ?? (_faker.Random.Bool() ? "/" : "C:\\Users\\"),
|
||||
ViewMode: viewMode ?? _faker.Random.Word(),
|
||||
IconSize: iconSize ?? _faker.Random.Word());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="ThemeFileSystemBrowserConfigurationDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ThemeFileSystemBrowserConfigurationDto"/> instances.</returns>
|
||||
public List<ThemeFileSystemBrowserConfigurationDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Themes;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Themes;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ThemeFileSystemBrowserDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ThemeFileSystemBrowserDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ThemeFileSystemBrowserDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="appBase">Optional absolute base URL of the Web application.</param>
|
||||
/// <param name="assetBase">Optional base URL of the theme assets.</param>
|
||||
/// <param name="iconBaseUrl">Optional base URL of the theme file type icons.</param>
|
||||
/// <param name="fileIconsUrl">Optional URL of the theme file icons mapping.</param>
|
||||
/// <param name="treeNodeTemplate">Optional raw template source of the tree view node.</param>
|
||||
/// <param name="explorerItemTemplate">Optional raw template source of the explorer item.</param>
|
||||
/// <param name="pathSegmentTemplate">Optional raw template source of the address bar path segment.</param>
|
||||
/// <param name="strings">Optional localized strings of the file system browser.</param>
|
||||
/// <returns>A configured <see cref="ThemeFileSystemBrowserDto"/> instance.</returns>
|
||||
public ThemeFileSystemBrowserDto Create(
|
||||
string? appBase = null,
|
||||
string? assetBase = null,
|
||||
string? iconBaseUrl = null,
|
||||
string? fileIconsUrl = null,
|
||||
string? treeNodeTemplate = null,
|
||||
string? explorerItemTemplate = null,
|
||||
string? pathSegmentTemplate = null,
|
||||
IReadOnlyDictionary<string, object?>? strings = null)
|
||||
{
|
||||
string themeId = _faker.Lorem.Word();
|
||||
return new ThemeFileSystemBrowserDto(
|
||||
AppBase: appBase ?? $"https://localhost:{_faker.Random.UShort()}/",
|
||||
AssetBase: assetBase ?? $"/theme-assets/{themeId}/assets",
|
||||
IconBaseUrl: iconBaseUrl ?? $"/theme-assets/{themeId}/assets/images/icons",
|
||||
FileIconsUrl: fileIconsUrl ?? $"/theme-assets/{themeId}/assets/file-icons.json",
|
||||
TreeNodeTemplate: treeNodeTemplate ?? "<div class=\"tree-node\" data-path=\"{{path}}\">{{name}}</div>",
|
||||
ExplorerItemTemplate: explorerItemTemplate ?? "<div class=\"e {{cssClass}}\" data-path=\"{{path}}\">{{name}}</div>",
|
||||
PathSegmentTemplate: pathSegmentTemplate ?? "<li id=\"{{id}}\">{{path}}</li>",
|
||||
Strings: strings ?? new Dictionary<string, object?> { ["cancel"] = "Cancel" });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="ThemeFileSystemBrowserDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ThemeFileSystemBrowserDto"/> instances.</returns>
|
||||
public List<ThemeFileSystemBrowserDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Themes;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Themes;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ThemeInfoDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ThemeInfoDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ThemeInfoDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional manifest id of the theme.</param>
|
||||
/// <param name="name">Optional display name of the theme.</param>
|
||||
/// <param name="description">Optional description of the theme.</param>
|
||||
/// <param name="author">Optional author of the theme.</param>
|
||||
/// <param name="version">Optional semantic version of the theme.</param>
|
||||
/// <param name="previewUrl">Optional URL of the theme preview image.</param>
|
||||
/// <param name="isBundled">Whether the theme ships with the application.</param>
|
||||
/// <param name="isDeleted">Whether the theme was deleted by the user.</param>
|
||||
/// <returns>A configured <see cref="ThemeInfoDto"/> instance.</returns>
|
||||
public ThemeInfoDto Create(
|
||||
string? id = null,
|
||||
string? name = null,
|
||||
string? description = null,
|
||||
string? author = null,
|
||||
string? version = null,
|
||||
string? previewUrl = null,
|
||||
bool? isBundled = null,
|
||||
bool? isDeleted = null)
|
||||
{
|
||||
return new ThemeInfoDto(
|
||||
Id: id ?? _faker.Lorem.Word(),
|
||||
Name: name ?? _faker.Commerce.ProductName(),
|
||||
Description: description ?? _faker.Lorem.Sentence(),
|
||||
Author: author ?? _faker.Name.FullName(),
|
||||
Version: version ?? _faker.System.Semver(),
|
||||
PreviewUrl: previewUrl ?? $"/theme-assets/{_faker.Lorem.Word()}/preview.png",
|
||||
IsBundled: isBundled ?? _faker.Random.Bool(),
|
||||
IsDeleted: isDeleted ?? _faker.Random.Bool()
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="ThemeInfoDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ThemeInfoDto"/> instances.</returns>
|
||||
public List<ThemeInfoDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Themes;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Themes;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ThemeLayoutPageDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ThemeLayoutPageDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ThemeLayoutPageDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="title">Optional. The title of the page, displayed by the themed shell.</param>
|
||||
/// <param name="content">Optional. The rendered HTML content of the page section.</param>
|
||||
/// <param name="script">Optional. The rendered script element of the page section, when the template defines one.</param>
|
||||
/// <returns>The created <see cref="ThemeLayoutPageDto"/>.</returns>
|
||||
public ThemeLayoutPageDto Create(
|
||||
string? title = null,
|
||||
string? content = null,
|
||||
string? script = null)
|
||||
{
|
||||
return new ThemeLayoutPageDto(
|
||||
title ?? _faker.Lorem.Word(),
|
||||
content ?? _faker.Lorem.Paragraph(),
|
||||
script ?? _faker.Lorem.Word());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ThemeLayoutPageDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ThemeLayoutPageDto"/> instances.</returns>
|
||||
public List<ThemeLayoutPageDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Themes;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Themes;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ThemeNavEntryDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ThemeNavEntryDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ThemeNavEntryDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="label">Optional label of the entry.</param>
|
||||
/// <param name="url">Optional URL of the link, or <see langword="null"/> for a submenu.</param>
|
||||
/// <param name="cssClass">Optional CSS classes of the link.</param>
|
||||
/// <param name="children">Optional child links of a submenu.</param>
|
||||
/// <param name="includeUrl">Whether the URL should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeCssClass">Whether the CSS class should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="ThemeNavEntryDto"/>.</returns>
|
||||
public ThemeNavEntryDto Create(
|
||||
string? label = null,
|
||||
string? url = null,
|
||||
string? cssClass = null,
|
||||
IReadOnlyList<ThemeNavEntryDto>? children = null,
|
||||
bool includeUrl = false,
|
||||
bool includeCssClass = false)
|
||||
{
|
||||
return new ThemeNavEntryDto(
|
||||
Label: label ?? _faker.Lorem.Word(),
|
||||
Url: includeUrl ? (url ?? _faker.Internet.Url()) : null,
|
||||
CssClass: includeCssClass ? (cssClass ?? _faker.Lorem.Word()) : null,
|
||||
Children: children ?? []);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ThemeNavEntryDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<ThemeNavEntryDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
Loaded 100 of 6450 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user