#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; /// /// Fixture class for the record. /// [ExcludeFromCodeCoverage] public class ConsumptionTotalsDtoFixture { private readonly Faker _faker = new(); private readonly MediaKindConsumptionSummaryDtoFixture _mediaKindConsumptionSummaryDtoFixture = new(); /// /// Creates a new instance with randomized test data. /// /// Optional total consumed duration, in seconds. /// Optional number of counted sessions. /// Optional number of completed sessions. /// Optional number of stopped sessions. /// Optional fraction of the counted sessions that completed. /// Optional consumption statistics broken down by media kind. /// Whether the media kind summaries should be included, or forced to an empty collection. /// A configured instance. public ConsumptionTotalsDto Create( double? totalConsumedDurationInSeconds = null, int? countedSessionCount = null, int? completedSessionCount = null, int? stoppedSessionCount = null, double? completionRate = null, IReadOnlyList? 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)]) : [] ); } /// /// Creates multiple instances with randomized test data. /// /// Number of instances to create. /// List of configured instances. public List CreateMany(int count = 3) { return [.. Enumerable.Range(0, count).Select(_ => Create())]; } }