mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 16: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
+55
@@ -0,0 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaPosition"/> value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaPositionFixture
|
||||
{
|
||||
private const int MAXIMUM_OFFSET_MILLISECONDS = 7_200_000;
|
||||
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MediaPosition"/>.
|
||||
/// </summary>
|
||||
/// <param name="kind">Optional. The kind of representation that the position uses. Defaults to a random valid kind.</param>
|
||||
/// <param name="timeOffset">Optional. The time offset of the position. Only used when <paramref name="kind"/> is <see cref="MediaPositionKind.TimeOffset"/>.</param>
|
||||
/// <param name="location">Optional. The location of the position. Only used when <paramref name="kind"/> is <see cref="MediaPositionKind.Location"/>.</param>
|
||||
/// <returns>The created <see cref="MediaPosition"/>.</returns>
|
||||
/// <remarks>
|
||||
/// The kind selects which representation is populated, so exactly one of <paramref name="timeOffset"/> and <paramref name="location"/> is used. A
|
||||
/// position always carries the representation of its own kind and can never carry both or neither, so no include flag is offered for them.
|
||||
/// There is no flag for an explicit empty <paramref name="location"/> either, because an empty string is already an explicit value.
|
||||
/// </remarks>
|
||||
public MediaPosition Create(
|
||||
MediaPositionKind? kind = null,
|
||||
TimeSpan? timeOffset = null,
|
||||
string? location = null)
|
||||
{
|
||||
MediaPositionKind resolvedKind = kind ?? _faker.Random.ArrayElement([MediaPositionKind.TimeOffset, MediaPositionKind.Location]);
|
||||
if (resolvedKind == MediaPositionKind.Location)
|
||||
return MediaPosition.CreateLocation(location ?? _faker.Lorem.Word());
|
||||
return MediaPosition.CreateTimeOffset(timeOffset ?? TimeSpan.FromMilliseconds(_faker.Random.Int(0, MAXIMUM_OFFSET_MILLISECONDS)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="MediaPosition"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaPosition"/> instances.</returns>
|
||||
public List<MediaPosition> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryId"/> value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The raw value of the library Id.</param>
|
||||
/// <returns>The created <see cref="LibraryId"/>.</returns>
|
||||
public LibraryId Create(
|
||||
Guid? value = null)
|
||||
{
|
||||
return LibraryId.Create(value ?? Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="LibraryId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="LibraryId"/> instances.</returns>
|
||||
public List<LibraryId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaItemId"/> value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaItemIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MediaItemId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The raw value of the media item Id.</param>
|
||||
/// <returns>The created <see cref="MediaItemId"/>.</returns>
|
||||
public MediaItemId Create(
|
||||
Guid? value = null)
|
||||
{
|
||||
return MediaItemId.Create(value ?? Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="MediaItemId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaItemId"/> instances.</returns>
|
||||
public List<MediaItemId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
|
||||
/// <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())];
|
||||
}
|
||||
}
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaConsumptionCompletedDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaConsumptionCompletedDomainEventFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly MediaConsumptionRecordIdFixture _mediaConsumptionRecordIdFixture = new();
|
||||
private readonly UserIdFixture _userIdFixture = new();
|
||||
private readonly LibraryIdFixture _libraryIdFixture = new();
|
||||
private readonly MediaItemIdFixture _mediaItemIdFixture = new();
|
||||
private readonly MediaPositionFixture _mediaPositionFixture = new();
|
||||
private readonly MediaKind[] _supportedMediaKinds =
|
||||
[
|
||||
MediaKind.MusicTrack,
|
||||
MediaKind.PodcastEpisode,
|
||||
MediaKind.Audiobook,
|
||||
MediaKind.Movie,
|
||||
MediaKind.TvEpisode,
|
||||
MediaKind.Book,
|
||||
MediaKind.Photo,
|
||||
MediaKind.Video
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MediaConsumptionCompletedDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="mediaConsumptionRecordId">Optional. The unique identifier of the consumption record.</param>
|
||||
/// <param name="userId">Optional. The unique identifier of the user that owns the consumption record.</param>
|
||||
/// <param name="libraryId">Optional. The unique identifier of the media library that contains the consumed item.</param>
|
||||
/// <param name="mediaItemId">Optional. The unique identifier of the consumed media item.</param>
|
||||
/// <param name="mediaKind">Optional. The kind of media that was consumed. Defaults to a random supported kind.</param>
|
||||
/// <param name="lastPosition">Optional. The last known position for the media item. Defaults to no position, unless <paramref name="includeLastPosition"/> is set.</param>
|
||||
/// <param name="includeLastPosition">Whether to generate a last position when none is supplied. Must be <see langword="false"/> for a photo, which has no position kind and accepts no position at all.</param>
|
||||
/// <param name="lastProgressFraction">Optional. The final progress fraction reported for the media item. Defaults to a bounded random fraction between zero and one.</param>
|
||||
/// <param name="consumedDuration">Optional. The active duration consumed by the session. Defaults to a bounded random duration.</param>
|
||||
/// <param name="consecutivePagesRead">Optional. The number of consecutive pages read in the session. Defaults to a bounded random count for a page based kind, and to zero for every other kind.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <returns>The created <see cref="MediaConsumptionCompletedDomainEvent"/>.</returns>
|
||||
public MediaConsumptionCompletedDomainEvent Create(
|
||||
Guid? id = null,
|
||||
MediaConsumptionRecordId? mediaConsumptionRecordId = null,
|
||||
UserId? userId = null,
|
||||
LibraryId? libraryId = null,
|
||||
MediaItemId? mediaItemId = null,
|
||||
MediaKind? mediaKind = null,
|
||||
Optional<MediaPosition>? lastPosition = null,
|
||||
bool includeLastPosition = false,
|
||||
double? lastProgressFraction = null,
|
||||
TimeSpan? consumedDuration = null,
|
||||
int? consecutivePagesRead = null,
|
||||
DateTime? occurredOnUtc = null)
|
||||
{
|
||||
MediaKind resolvedMediaKind = mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds);
|
||||
Optional<MediaConsumptionRule> ruleResult = MediaConsumptionRule.For(resolvedMediaKind);
|
||||
bool isPageBased = ruleResult.HasValue && ruleResult.Value is PageThresholdConsumptionRule;
|
||||
|
||||
return new MediaConsumptionCompletedDomainEvent(
|
||||
id ?? Guid.NewGuid(),
|
||||
mediaConsumptionRecordId ?? _mediaConsumptionRecordIdFixture.Create(),
|
||||
userId ?? _userIdFixture.Create(),
|
||||
libraryId ?? _libraryIdFixture.Create(),
|
||||
mediaItemId ?? _mediaItemIdFixture.Create(),
|
||||
resolvedMediaKind,
|
||||
lastPosition ?? ResolveLastPosition(includeLastPosition, ruleResult),
|
||||
lastProgressFraction ?? _faker.Random.Double(0, 1),
|
||||
consumedDuration ?? TimeSpan.FromSeconds(_faker.Random.Int(0, 36000)),
|
||||
consecutivePagesRead ?? (isPageBased ? _faker.Random.Int(0, 100) : 0),
|
||||
occurredOnUtc ?? DateTime.UtcNow);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the last position of the domain event, keeping it consistent with the position kind of the media kind rule.
|
||||
/// </summary>
|
||||
/// <param name="includeLastPosition">Whether to generate a position.</param>
|
||||
/// <param name="ruleResult">The consumption rule of the media kind of the domain event, if the kind has one.</param>
|
||||
/// <returns>The resolved last position, or no value when the domain event carries no position.</returns>
|
||||
private Optional<MediaPosition> ResolveLastPosition(bool includeLastPosition, Optional<MediaConsumptionRule> ruleResult)
|
||||
{
|
||||
if (!includeLastPosition)
|
||||
return Optional<MediaPosition>.None();
|
||||
if (!ruleResult.HasValue || !ruleResult.Value.PositionKind.HasValue)
|
||||
return Optional<MediaPosition>.None();
|
||||
return Optional<MediaPosition>.Some(_mediaPositionFixture.Create(kind: ruleResult.Value.PositionKind.Value));
|
||||
}
|
||||
}
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaConsumptionProgressedDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaConsumptionProgressedDomainEventFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly MediaConsumptionRecordIdFixture _mediaConsumptionRecordIdFixture = new();
|
||||
private readonly UserIdFixture _userIdFixture = new();
|
||||
private readonly LibraryIdFixture _libraryIdFixture = new();
|
||||
private readonly MediaItemIdFixture _mediaItemIdFixture = new();
|
||||
private readonly MediaPositionFixture _mediaPositionFixture = new();
|
||||
private readonly MediaKind[] _supportedMediaKinds =
|
||||
[
|
||||
MediaKind.MusicTrack,
|
||||
MediaKind.PodcastEpisode,
|
||||
MediaKind.Audiobook,
|
||||
MediaKind.Movie,
|
||||
MediaKind.TvEpisode,
|
||||
MediaKind.Book,
|
||||
MediaKind.Photo,
|
||||
MediaKind.Video
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MediaConsumptionProgressedDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="mediaConsumptionRecordId">Optional. The unique identifier of the consumption record.</param>
|
||||
/// <param name="userId">Optional. The unique identifier of the user that owns the consumption record.</param>
|
||||
/// <param name="libraryId">Optional. The unique identifier of the media library that contains the consumed item.</param>
|
||||
/// <param name="mediaItemId">Optional. The unique identifier of the consumed media item.</param>
|
||||
/// <param name="mediaKind">Optional. The kind of media that is being consumed. Defaults to a random supported kind.</param>
|
||||
/// <param name="lastPosition">Optional. The last known position for the media item. Defaults to no position, unless <paramref name="includeLastPosition"/> is set.</param>
|
||||
/// <param name="includeLastPosition">Whether to generate a last position when none is supplied. Must be <see langword="false"/> for a photo, which has no position kind and accepts no position at all.</param>
|
||||
/// <param name="lastProgressFraction">Optional. The last progress fraction reported by the client. Defaults to a bounded random fraction between zero and one.</param>
|
||||
/// <param name="consumedDuration">Optional. The active duration consumed so far. Defaults to a bounded random duration.</param>
|
||||
/// <param name="consecutivePagesRead">Optional. The number of consecutive pages read so far. Defaults to a bounded random count for a page based kind, and to zero for every other kind.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <returns>The created <see cref="MediaConsumptionProgressedDomainEvent"/>.</returns>
|
||||
public MediaConsumptionProgressedDomainEvent Create(
|
||||
Guid? id = null,
|
||||
MediaConsumptionRecordId? mediaConsumptionRecordId = null,
|
||||
UserId? userId = null,
|
||||
LibraryId? libraryId = null,
|
||||
MediaItemId? mediaItemId = null,
|
||||
MediaKind? mediaKind = null,
|
||||
Optional<MediaPosition>? lastPosition = null,
|
||||
bool includeLastPosition = false,
|
||||
double? lastProgressFraction = null,
|
||||
TimeSpan? consumedDuration = null,
|
||||
int? consecutivePagesRead = null,
|
||||
DateTime? occurredOnUtc = null)
|
||||
{
|
||||
MediaKind resolvedMediaKind = mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds);
|
||||
Optional<MediaConsumptionRule> ruleResult = MediaConsumptionRule.For(resolvedMediaKind);
|
||||
bool isPageBased = ruleResult.HasValue && ruleResult.Value is PageThresholdConsumptionRule;
|
||||
|
||||
return new MediaConsumptionProgressedDomainEvent(
|
||||
id ?? Guid.NewGuid(),
|
||||
mediaConsumptionRecordId ?? _mediaConsumptionRecordIdFixture.Create(),
|
||||
userId ?? _userIdFixture.Create(),
|
||||
libraryId ?? _libraryIdFixture.Create(),
|
||||
mediaItemId ?? _mediaItemIdFixture.Create(),
|
||||
resolvedMediaKind,
|
||||
lastPosition ?? ResolveLastPosition(includeLastPosition, ruleResult),
|
||||
lastProgressFraction ?? _faker.Random.Double(0, 1),
|
||||
consumedDuration ?? TimeSpan.FromSeconds(_faker.Random.Int(0, 36000)),
|
||||
consecutivePagesRead ?? (isPageBased ? _faker.Random.Int(0, 100) : 0),
|
||||
occurredOnUtc ?? DateTime.UtcNow);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the last position of the domain event, keeping it consistent with the position kind of the media kind rule.
|
||||
/// </summary>
|
||||
/// <param name="includeLastPosition">Whether to generate a position.</param>
|
||||
/// <param name="ruleResult">The consumption rule of the media kind of the domain event, if the kind has one.</param>
|
||||
/// <returns>The resolved last position, or no value when the domain event carries no position.</returns>
|
||||
private Optional<MediaPosition> ResolveLastPosition(bool includeLastPosition, Optional<MediaConsumptionRule> ruleResult)
|
||||
{
|
||||
if (!includeLastPosition)
|
||||
return Optional<MediaPosition>.None();
|
||||
if (!ruleResult.HasValue || !ruleResult.Value.PositionKind.HasValue)
|
||||
return Optional<MediaPosition>.None();
|
||||
return Optional<MediaPosition>.Some(_mediaPositionFixture.Create(kind: ruleResult.Value.PositionKind.Value));
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaConsumptionStartedDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaConsumptionStartedDomainEventFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly MediaConsumptionRecordIdFixture _mediaConsumptionRecordIdFixture = new();
|
||||
private readonly UserIdFixture _userIdFixture = new();
|
||||
private readonly LibraryIdFixture _libraryIdFixture = new();
|
||||
private readonly MediaItemIdFixture _mediaItemIdFixture = new();
|
||||
private readonly MediaKind[] _supportedMediaKinds =
|
||||
[
|
||||
MediaKind.MusicTrack,
|
||||
MediaKind.PodcastEpisode,
|
||||
MediaKind.Audiobook,
|
||||
MediaKind.Movie,
|
||||
MediaKind.TvEpisode,
|
||||
MediaKind.Book,
|
||||
MediaKind.Photo,
|
||||
MediaKind.Video
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MediaConsumptionStartedDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="mediaConsumptionRecordId">Optional. The unique identifier of the consumption record.</param>
|
||||
/// <param name="userId">Optional. The unique identifier of the user that started the session.</param>
|
||||
/// <param name="libraryId">Optional. The unique identifier of the media library that contains the consumed item.</param>
|
||||
/// <param name="mediaItemId">Optional. The unique identifier of the consumed media item.</param>
|
||||
/// <param name="mediaKind">Optional. The kind of media that is being consumed. Defaults to a random supported kind.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <returns>The created <see cref="MediaConsumptionStartedDomainEvent"/>.</returns>
|
||||
public MediaConsumptionStartedDomainEvent Create(
|
||||
Guid? id = null,
|
||||
MediaConsumptionRecordId? mediaConsumptionRecordId = null,
|
||||
UserId? userId = null,
|
||||
LibraryId? libraryId = null,
|
||||
MediaItemId? mediaItemId = null,
|
||||
MediaKind? mediaKind = null,
|
||||
DateTime? occurredOnUtc = null)
|
||||
{
|
||||
return new MediaConsumptionStartedDomainEvent(
|
||||
id ?? Guid.NewGuid(),
|
||||
mediaConsumptionRecordId ?? _mediaConsumptionRecordIdFixture.Create(),
|
||||
userId ?? _userIdFixture.Create(),
|
||||
libraryId ?? _libraryIdFixture.Create(),
|
||||
mediaItemId ?? _mediaItemIdFixture.Create(),
|
||||
mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds),
|
||||
occurredOnUtc ?? DateTime.UtcNow);
|
||||
}
|
||||
}
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaConsumptionStoppedDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaConsumptionStoppedDomainEventFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly MediaConsumptionRecordIdFixture _mediaConsumptionRecordIdFixture = new();
|
||||
private readonly UserIdFixture _userIdFixture = new();
|
||||
private readonly LibraryIdFixture _libraryIdFixture = new();
|
||||
private readonly MediaItemIdFixture _mediaItemIdFixture = new();
|
||||
private readonly MediaPositionFixture _mediaPositionFixture = new();
|
||||
private readonly MediaKind[] _supportedMediaKinds =
|
||||
[
|
||||
MediaKind.MusicTrack,
|
||||
MediaKind.PodcastEpisode,
|
||||
MediaKind.Audiobook,
|
||||
MediaKind.Movie,
|
||||
MediaKind.TvEpisode,
|
||||
MediaKind.Book,
|
||||
MediaKind.Photo,
|
||||
MediaKind.Video
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MediaConsumptionStoppedDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="mediaConsumptionRecordId">Optional. The unique identifier of the consumption record.</param>
|
||||
/// <param name="userId">Optional. The unique identifier of the user that owns the consumption record.</param>
|
||||
/// <param name="libraryId">Optional. The unique identifier of the media library that contains the consumed item.</param>
|
||||
/// <param name="mediaItemId">Optional. The unique identifier of the consumed media item.</param>
|
||||
/// <param name="mediaKind">Optional. The kind of media that was consumed. Defaults to a random supported kind.</param>
|
||||
/// <param name="lastPosition">Optional. The last known position for the media item. Defaults to no position, unless <paramref name="includeLastPosition"/> is set.</param>
|
||||
/// <param name="includeLastPosition">Whether to generate a last position when none is supplied. Must be <see langword="false"/> for a photo, which has no position kind and accepts no position at all.</param>
|
||||
/// <param name="lastProgressFraction">Optional. The final progress fraction reported for the media item. Defaults to a bounded random fraction between zero and one.</param>
|
||||
/// <param name="consumedDuration">Optional. The active duration consumed by the session. Defaults to a bounded random duration.</param>
|
||||
/// <param name="consecutivePagesRead">Optional. The number of consecutive pages read in the session. Defaults to a bounded random count for a page based kind, and to zero for every other kind.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <returns>The created <see cref="MediaConsumptionStoppedDomainEvent"/>.</returns>
|
||||
public MediaConsumptionStoppedDomainEvent Create(
|
||||
Guid? id = null,
|
||||
MediaConsumptionRecordId? mediaConsumptionRecordId = null,
|
||||
UserId? userId = null,
|
||||
LibraryId? libraryId = null,
|
||||
MediaItemId? mediaItemId = null,
|
||||
MediaKind? mediaKind = null,
|
||||
Optional<MediaPosition>? lastPosition = null,
|
||||
bool includeLastPosition = false,
|
||||
double? lastProgressFraction = null,
|
||||
TimeSpan? consumedDuration = null,
|
||||
int? consecutivePagesRead = null,
|
||||
DateTime? occurredOnUtc = null)
|
||||
{
|
||||
MediaKind resolvedMediaKind = mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds);
|
||||
Optional<MediaConsumptionRule> ruleResult = MediaConsumptionRule.For(resolvedMediaKind);
|
||||
bool isPageBased = ruleResult.HasValue && ruleResult.Value is PageThresholdConsumptionRule;
|
||||
|
||||
return new MediaConsumptionStoppedDomainEvent(
|
||||
id ?? Guid.NewGuid(),
|
||||
mediaConsumptionRecordId ?? _mediaConsumptionRecordIdFixture.Create(),
|
||||
userId ?? _userIdFixture.Create(),
|
||||
libraryId ?? _libraryIdFixture.Create(),
|
||||
mediaItemId ?? _mediaItemIdFixture.Create(),
|
||||
resolvedMediaKind,
|
||||
lastPosition ?? ResolveLastPosition(includeLastPosition, ruleResult),
|
||||
lastProgressFraction ?? _faker.Random.Double(0, 1),
|
||||
consumedDuration ?? TimeSpan.FromSeconds(_faker.Random.Int(0, 36000)),
|
||||
consecutivePagesRead ?? (isPageBased ? _faker.Random.Int(0, 100) : 0),
|
||||
occurredOnUtc ?? DateTime.UtcNow);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the last position of the domain event, keeping it consistent with the position kind of the media kind rule.
|
||||
/// </summary>
|
||||
/// <param name="includeLastPosition">Whether to generate a position.</param>
|
||||
/// <param name="ruleResult">The consumption rule of the media kind of the domain event, if the kind has one.</param>
|
||||
/// <returns>The resolved last position, or no value when the domain event carries no position.</returns>
|
||||
private Optional<MediaPosition> ResolveLastPosition(bool includeLastPosition, Optional<MediaConsumptionRule> ruleResult)
|
||||
{
|
||||
if (!includeLastPosition)
|
||||
return Optional<MediaPosition>.None();
|
||||
if (!ruleResult.HasValue || !ruleResult.Value.PositionKind.HasValue)
|
||||
return Optional<MediaPosition>.None();
|
||||
return Optional<MediaPosition>.Some(_mediaPositionFixture.Create(kind: ruleResult.Value.PositionKind.Value));
|
||||
}
|
||||
}
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaConsumptionRecord"/> domain aggregate.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaConsumptionRecordFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly MediaConsumptionRecordIdFixture _mediaConsumptionRecordIdFixture = new();
|
||||
private readonly UserIdFixture _userIdFixture = new();
|
||||
private readonly LibraryIdFixture _libraryIdFixture = new();
|
||||
private readonly MediaItemIdFixture _mediaItemIdFixture = new();
|
||||
private readonly MediaPositionFixture _mediaPositionFixture = new();
|
||||
private readonly MediaKind[] _supportedMediaKinds =
|
||||
[
|
||||
MediaKind.MusicTrack,
|
||||
MediaKind.PodcastEpisode,
|
||||
MediaKind.Audiobook,
|
||||
MediaKind.Movie,
|
||||
MediaKind.TvEpisode,
|
||||
MediaKind.Book,
|
||||
MediaKind.Photo,
|
||||
MediaKind.Video
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MediaConsumptionRecord"/> domain aggregate, with pre-existing data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the consumption record.</param>
|
||||
/// <param name="userId">Optional. The Id of the user that owns the consumption record.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library that contains the consumed media item.</param>
|
||||
/// <param name="mediaItemId">Optional. The Id of the consumed media item.</param>
|
||||
/// <param name="mediaKind">Optional. The kind of media that is consumed. Defaults to a random supported kind.</param>
|
||||
/// <param name="status">Optional. The status of the consumption session. Defaults to a random valid status.</param>
|
||||
/// <param name="startedOnUtc">Optional. The date and time when the consumption session started. Defaults to a few days in the past.</param>
|
||||
/// <param name="lastActivityOnUtc">Optional. The date and time of the last activity of the consumption session. Defaults to a moment at or after the start.</param>
|
||||
/// <param name="endedOnUtc">Optional. The date and time when the consumption session ended. Defaults to no value for an in-progress session, and to a moment at or after the last activity for a terminal session.</param>
|
||||
/// <param name="consumedDuration">Optional. The active duration consumed by the session. Defaults to a bounded random duration.</param>
|
||||
/// <param name="lastPosition">Optional. The last position of the session. When omitted, a position matching the position kind of the media kind rule is generated.</param>
|
||||
/// <param name="includeLastPosition">Whether to generate a last position when <paramref name="lastPosition"/> is not supplied. Must be <see langword="false"/> for a photo, which has no position kind and accepts no position at all.</param>
|
||||
/// <param name="lastProgressFraction">Optional. The last progress fraction of the session. Defaults to a bounded random fraction between zero and one.</param>
|
||||
/// <param name="consecutivePagesRead">Optional. The number of consecutive pages read. Defaults to a bounded random count for a page based kind, and to zero for every other kind.</param>
|
||||
/// <returns>The created <see cref="MediaConsumptionRecord"/>.</returns>
|
||||
/// <remarks>
|
||||
/// The record is built through <see cref="MediaConsumptionRecord.Reconstitute"/>, so every default produced here is internally consistent: the
|
||||
/// start is in the past, the last activity never precedes it, an end time exists exactly when the status is terminal and never precedes the last
|
||||
/// activity, consecutive pages are only counted for a book, and a generated position always uses the position kind of its media kind.
|
||||
/// </remarks>
|
||||
public MediaConsumptionRecord Create(
|
||||
MediaConsumptionRecordId? id = null,
|
||||
UserId? userId = null,
|
||||
LibraryId? libraryId = null,
|
||||
MediaItemId? mediaItemId = null,
|
||||
MediaKind? mediaKind = null,
|
||||
ConsumptionStatus? status = null,
|
||||
DateTime? startedOnUtc = null,
|
||||
DateTime? lastActivityOnUtc = null,
|
||||
Optional<DateTime>? endedOnUtc = null,
|
||||
TimeSpan? consumedDuration = null,
|
||||
Optional<MediaPosition>? lastPosition = null,
|
||||
bool includeLastPosition = true,
|
||||
double? lastProgressFraction = null,
|
||||
int? consecutivePagesRead = null)
|
||||
{
|
||||
MediaKind resolvedMediaKind = mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds);
|
||||
ConsumptionStatus resolvedStatus = status ?? _faker.Random.ArrayElement([ConsumptionStatus.InProgress, ConsumptionStatus.Completed, ConsumptionStatus.Stopped]);
|
||||
DateTime resolvedStartedOnUtc = startedOnUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)).AddMinutes(-_faker.Random.Int(0, 59));
|
||||
DateTime resolvedLastActivityOnUtc = lastActivityOnUtc ?? resolvedStartedOnUtc.AddMinutes(_faker.Random.Int(0, 120));
|
||||
Optional<DateTime> resolvedEndedOnUtc = endedOnUtc ?? (resolvedStatus == ConsumptionStatus.InProgress
|
||||
? Optional<DateTime>.None()
|
||||
: Optional<DateTime>.Some(resolvedLastActivityOnUtc == DateTime.MaxValue
|
||||
? DateTime.MaxValue
|
||||
: resolvedLastActivityOnUtc.AddMinutes(_faker.Random.Int(0, 60))));
|
||||
Optional<MediaConsumptionRule> ruleResult = MediaConsumptionRule.For(resolvedMediaKind);
|
||||
bool isPageBased = ruleResult.HasValue && ruleResult.Value is PageThresholdConsumptionRule;
|
||||
|
||||
Result<MediaConsumptionRecord> result = MediaConsumptionRecord.Reconstitute(
|
||||
id ?? _mediaConsumptionRecordIdFixture.Create(),
|
||||
userId ?? _userIdFixture.Create(),
|
||||
libraryId ?? _libraryIdFixture.Create(),
|
||||
mediaItemId ?? _mediaItemIdFixture.Create(),
|
||||
resolvedMediaKind,
|
||||
resolvedStatus,
|
||||
resolvedStartedOnUtc,
|
||||
resolvedLastActivityOnUtc,
|
||||
resolvedEndedOnUtc,
|
||||
consumedDuration ?? TimeSpan.FromSeconds(_faker.Random.Int(0, 36000)),
|
||||
ResolveLastPosition(lastPosition, includeLastPosition, ruleResult),
|
||||
lastProgressFraction ?? _faker.Random.Double(0, 1),
|
||||
consecutivePagesRead ?? (isPageBased ? _faker.Random.Int(0, 100) : 0));
|
||||
return result.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MediaConsumptionRecord"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaConsumptionRecord"/> instances.</returns>
|
||||
public List<MediaConsumptionRecord> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the last position of the record, keeping it consistent with the position kind of its media kind rule.
|
||||
/// </summary>
|
||||
/// <param name="lastPosition">The explicitly supplied last position, if any.</param>
|
||||
/// <param name="includeLastPosition">Whether to generate a position when none is supplied.</param>
|
||||
/// <param name="ruleResult">The consumption rule of the media kind of the record, if the kind has one.</param>
|
||||
/// <returns>The resolved last position, or no value when the record carries no position.</returns>
|
||||
private Optional<MediaPosition> ResolveLastPosition(Optional<MediaPosition>? lastPosition, bool includeLastPosition, Optional<MediaConsumptionRule> ruleResult)
|
||||
{
|
||||
if (!includeLastPosition)
|
||||
return Optional<MediaPosition>.None();
|
||||
if (lastPosition.HasValue)
|
||||
return lastPosition.Value;
|
||||
if (!ruleResult.HasValue || !ruleResult.Value.PositionKind.HasValue)
|
||||
return Optional<MediaPosition>.None();
|
||||
return Optional<MediaPosition>.Some(_mediaPositionFixture.Create(kind: ruleResult.Value.PositionKind.Value));
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AudiobookConsumptionRule"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AudiobookConsumptionRuleFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a valid <see cref="AudiobookConsumptionRule"/>.
|
||||
/// </summary>
|
||||
/// <returns>The created <see cref="AudiobookConsumptionRule"/>.</returns>
|
||||
public AudiobookConsumptionRule Create()
|
||||
{
|
||||
return new AudiobookConsumptionRule();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="AudiobookConsumptionRule"/> instances.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="AudiobookConsumptionRule"/> instances.</returns>
|
||||
public List<AudiobookConsumptionRule> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="BookConsumptionRule"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BookConsumptionRuleFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a valid <see cref="BookConsumptionRule"/>.
|
||||
/// </summary>
|
||||
/// <returns>The created <see cref="BookConsumptionRule"/>.</returns>
|
||||
public BookConsumptionRule Create()
|
||||
{
|
||||
return new BookConsumptionRule();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="BookConsumptionRule"/> instances.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="BookConsumptionRule"/> instances.</returns>
|
||||
public List<BookConsumptionRule> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaConsumptionRecordId"/> value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaConsumptionRecordIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MediaConsumptionRecordId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The raw value of the consumption record Id.</param>
|
||||
/// <returns>The created <see cref="MediaConsumptionRecordId"/>.</returns>
|
||||
public MediaConsumptionRecordId Create(
|
||||
Guid? value = null)
|
||||
{
|
||||
return MediaConsumptionRecordId.Create(value ?? Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="MediaConsumptionRecordId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaConsumptionRecordId"/> instances.</returns>
|
||||
public List<MediaConsumptionRecordId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MovieConsumptionRule"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MovieConsumptionRuleFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a valid <see cref="MovieConsumptionRule"/>.
|
||||
/// </summary>
|
||||
/// <returns>The created <see cref="MovieConsumptionRule"/>.</returns>
|
||||
public MovieConsumptionRule Create()
|
||||
{
|
||||
return new MovieConsumptionRule();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MovieConsumptionRule"/> instances.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MovieConsumptionRule"/> instances.</returns>
|
||||
public List<MovieConsumptionRule> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MusicTrackConsumptionRule"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MusicTrackConsumptionRuleFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a valid <see cref="MusicTrackConsumptionRule"/>.
|
||||
/// </summary>
|
||||
/// <returns>The created <see cref="MusicTrackConsumptionRule"/>.</returns>
|
||||
public MusicTrackConsumptionRule Create()
|
||||
{
|
||||
return new MusicTrackConsumptionRule();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MusicTrackConsumptionRule"/> instances.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MusicTrackConsumptionRule"/> instances.</returns>
|
||||
public List<MusicTrackConsumptionRule> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PhotoConsumptionRule"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PhotoConsumptionRuleFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a valid <see cref="PhotoConsumptionRule"/>.
|
||||
/// </summary>
|
||||
/// <returns>The created <see cref="PhotoConsumptionRule"/>.</returns>
|
||||
public PhotoConsumptionRule Create()
|
||||
{
|
||||
return new PhotoConsumptionRule();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="PhotoConsumptionRule"/> instances.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PhotoConsumptionRule"/> instances.</returns>
|
||||
public List<PhotoConsumptionRule> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PodcastEpisodeConsumptionRule"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PodcastEpisodeConsumptionRuleFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a valid <see cref="PodcastEpisodeConsumptionRule"/>.
|
||||
/// </summary>
|
||||
/// <returns>The created <see cref="PodcastEpisodeConsumptionRule"/>.</returns>
|
||||
public PodcastEpisodeConsumptionRule Create()
|
||||
{
|
||||
return new PodcastEpisodeConsumptionRule();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="PodcastEpisodeConsumptionRule"/> instances.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PodcastEpisodeConsumptionRule"/> instances.</returns>
|
||||
public List<PodcastEpisodeConsumptionRule> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="TvEpisodeConsumptionRule"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class TvEpisodeConsumptionRuleFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a valid <see cref="TvEpisodeConsumptionRule"/>.
|
||||
/// </summary>
|
||||
/// <returns>The created <see cref="TvEpisodeConsumptionRule"/>.</returns>
|
||||
public TvEpisodeConsumptionRule Create()
|
||||
{
|
||||
return new TvEpisodeConsumptionRule();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="TvEpisodeConsumptionRule"/> instances.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="TvEpisodeConsumptionRule"/> instances.</returns>
|
||||
public List<TvEpisodeConsumptionRule> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="VideoConsumptionRule"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class VideoConsumptionRuleFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a valid <see cref="VideoConsumptionRule"/>.
|
||||
/// </summary>
|
||||
/// <returns>The created <see cref="VideoConsumptionRule"/>.</returns>
|
||||
public VideoConsumptionRule Create()
|
||||
{
|
||||
return new VideoConsumptionRule();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="VideoConsumptionRule"/> instances.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="VideoConsumptionRule"/> instances.</returns>
|
||||
public List<VideoConsumptionRule> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaResumePointAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaResumePointAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaResumePointAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaResumePointAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaResumePoint"/> domain aggregate.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaResumePointFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly MediaResumePointIdFixture _mediaResumePointIdFixture = new();
|
||||
private readonly UserIdFixture _userIdFixture = new();
|
||||
private readonly LibraryIdFixture _libraryIdFixture = new();
|
||||
private readonly MediaItemIdFixture _mediaItemIdFixture = new();
|
||||
private readonly MediaPositionFixture _mediaPositionFixture = new();
|
||||
private readonly MediaKind[] _resumableMediaKinds =
|
||||
[
|
||||
MediaKind.MusicTrack,
|
||||
MediaKind.PodcastEpisode,
|
||||
MediaKind.Audiobook,
|
||||
MediaKind.Movie,
|
||||
MediaKind.TvEpisode,
|
||||
MediaKind.Book,
|
||||
MediaKind.Video
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MediaResumePoint"/> domain aggregate, with pre-existing data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the resume point.</param>
|
||||
/// <param name="userId">Optional. The Id of the user that owns 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. When omitted, a position matching the position kind of the media kind rule is generated.</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>
|
||||
/// <param name="createdOnUtc">Optional. The date and time when the resume point was created. Defaults to the resolved last consumption time.</param>
|
||||
/// <param name="updatedOnUtc">Optional. The date and time when the resume point was last updated. Defaults to no value.</param>
|
||||
/// <returns>The created <see cref="MediaResumePoint"/>.</returns>
|
||||
/// <remarks>
|
||||
/// The resume point is built through <see cref="MediaResumePoint.Reconstitute"/>, so every default produced here is internally consistent: the
|
||||
/// media kind is always one that can be resumed, a generated position always uses the position kind of its media kind rule, the progress fraction
|
||||
/// stays within its boundaries, the last consumption time is in the past and the creation time defaults to it. The fixture must never be used with a
|
||||
/// non-resumable kind, such as <see cref="MediaKind.Photo"/>, or with an unsupported kind, because no valid resume point exists for them. A resume
|
||||
/// point always carries a position, so the fixture generates one whenever <paramref name="lastPosition"/> is omitted.
|
||||
/// </remarks>
|
||||
public MediaResumePoint Create(
|
||||
MediaResumePointId? id = null,
|
||||
UserId? userId = null,
|
||||
LibraryId? libraryId = null,
|
||||
MediaItemId? mediaItemId = null,
|
||||
MediaKind? mediaKind = null,
|
||||
MediaPosition? lastPosition = null,
|
||||
double? lastProgressFraction = null,
|
||||
DateTime? lastConsumedOnUtc = null,
|
||||
DateTime? createdOnUtc = null,
|
||||
Optional<DateTime>? updatedOnUtc = null)
|
||||
{
|
||||
MediaKind resolvedMediaKind = mediaKind ?? _faker.Random.ArrayElement(_resumableMediaKinds);
|
||||
MediaConsumptionRule rule = MediaConsumptionRule.For(resolvedMediaKind).Value;
|
||||
DateTime resolvedLastConsumedOnUtc = lastConsumedOnUtc ?? DateTime.UtcNow.AddHours(-_faker.Random.Int(1, 720));
|
||||
MediaPosition resolvedLastPosition = lastPosition ?? _mediaPositionFixture.Create(kind: rule.PositionKind.Value);
|
||||
|
||||
Result<MediaResumePoint> result = MediaResumePoint.Reconstitute(
|
||||
id ?? _mediaResumePointIdFixture.Create(),
|
||||
userId ?? _userIdFixture.Create(),
|
||||
libraryId ?? _libraryIdFixture.Create(),
|
||||
mediaItemId ?? _mediaItemIdFixture.Create(),
|
||||
resolvedMediaKind,
|
||||
resolvedLastPosition,
|
||||
lastProgressFraction ?? _faker.Random.Double(0, 1),
|
||||
resolvedLastConsumedOnUtc,
|
||||
createdOnUtc ?? resolvedLastConsumedOnUtc,
|
||||
updatedOnUtc ?? Optional<DateTime>.None());
|
||||
return result.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MediaResumePoint"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaResumePoint"/> instances.</returns>
|
||||
public List<MediaResumePoint> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaResumePointAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaResumePointAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaResumePointId"/> value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaResumePointIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MediaResumePointId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The raw value of the resume point Id.</param>
|
||||
/// <returns>The created <see cref="MediaResumePointId"/>.</returns>
|
||||
public MediaResumePointId Create(
|
||||
Guid? value = null)
|
||||
{
|
||||
return MediaResumePointId.Create(value ?? Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="MediaResumePointId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaResumePointId"/> instances.</returns>
|
||||
public List<MediaResumePointId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user