mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 18:21:10 +00:00
Hardens test assertions and adds missing test coverage.
This commit is contained in:
1 parent
6b86fd5805
commit
1189bbaf36
489 files changed
+39982
-512
No files matched your search
+44
@@ -0,0 +1,44 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="User"/> domain aggregate.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UserFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="User"/> domain aggregate.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The user Id.</param>
|
||||
/// <param name="username">Optional. The username of the user.</param>
|
||||
/// <returns>The created <see cref="User"/>.</returns>
|
||||
public User Create(Guid? id = null, string? username = null)
|
||||
{
|
||||
UserId userId = id is null ? UserId.CreateUnique() : UserId.Create(id.Value);
|
||||
Result<User> user = User.Create(userId, username ?? _faker.Internet.UserName());
|
||||
return user.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="User"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="User"/> instances.</returns>
|
||||
public List<User> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="UserId"/> value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UserIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="UserId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The raw value of the user Id.</param>
|
||||
/// <returns>The created <see cref="UserId"/>.</returns>
|
||||
public UserId Create(Guid? value = null)
|
||||
{
|
||||
return UserId.Create(value ?? Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="UserId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="UserId"/> instances.</returns>
|
||||
public List<UserId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserSettingsAggregate;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.UserManagementBoundedContext.UserSettingsAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="UserSettings"/> domain aggregate.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UserSettingsFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="UserSettings"/> domain aggregate.
|
||||
/// </summary>
|
||||
/// <param name="userId">Optional. The Id of the user that owns the settings.</param>
|
||||
/// <param name="isPaginationEnabled">Whether pagination is enabled for the user.</param>
|
||||
/// <param name="itemsPerPage">The number of library items displayed per page when pagination is enabled.</param>
|
||||
/// <param name="ignoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker.</param>
|
||||
/// <returns>The created <see cref="UserSettings"/>.</returns>
|
||||
public UserSettings Create(
|
||||
Guid? userId = null,
|
||||
bool isPaginationEnabled = true,
|
||||
int itemsPerPage = 48,
|
||||
bool ignoreThePrefixForAlphaPicker = false)
|
||||
{
|
||||
Result<UserSettings> settings = UserSettings.Create(
|
||||
userId is null ? UserId.CreateUnique() : UserId.Create(userId.Value),
|
||||
isPaginationEnabled,
|
||||
itemsPerPage,
|
||||
ignoreThePrefixForAlphaPicker);
|
||||
return settings.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="UserSettings"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="UserSettings"/> instances.</returns>
|
||||
public List<UserSettings> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user