mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 16:11: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
+57
@@ -0,0 +1,57 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.MovieLibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.MovieLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.VideoLibraryBoundedContext.MovieLibraryAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.VideoLibraryBoundedContext.MovieLibraryAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="Movie"/> domain aggregate.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MovieFixture
|
||||
{
|
||||
private readonly VideoMetadataFixture _videoMetadataFixture = new();
|
||||
private readonly MovieIdFixture _movieIdFixture = new();
|
||||
private readonly MediaContributorIdFixture _mediaContributorIdFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="Movie"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The unique identifier of the movie.</param>
|
||||
/// <param name="metadata">Optional. The metadata of the movie.</param>
|
||||
/// <param name="contributors">Optional. The list of media contributors of the movie.</param>
|
||||
/// <param name="ratings">Optional. The list of ratings for the movie.</param>
|
||||
/// <returns>The created <see cref="Movie"/>.</returns>
|
||||
public Movie Create(
|
||||
MovieId? id = null,
|
||||
VideoMetadata? metadata = null,
|
||||
List<MediaContributorId>? contributors = null,
|
||||
List<Rating>? ratings = null)
|
||||
{
|
||||
return Movie.Create(
|
||||
id ?? _movieIdFixture.Create(),
|
||||
metadata ?? _videoMetadataFixture.Create(),
|
||||
contributors ?? [_mediaContributorIdFixture.Create()],
|
||||
ratings ?? []).Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="Movie"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="Movie"/> instances.</returns>
|
||||
public List<Movie> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.MovieLibraryAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.VideoLibraryBoundedContext.MovieLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MovieId"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MovieIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MovieId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The value used to create the <see cref="MovieId"/>. If not provided, a random value is generated.</param>
|
||||
/// <returns>The created <see cref="MovieId"/>.</returns>
|
||||
public MovieId Create(Guid? value = null)
|
||||
{
|
||||
return value is null ? MovieId.CreateUnique() : MovieId.Create(value.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MovieId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MovieId"/> instances.</returns>
|
||||
public List<MovieId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.MovieLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Common.ValueObjects.Metadata;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.VideoLibraryBoundedContext.MovieLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="VideoMetadata"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class VideoMetadataFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly GenreFixture _genreFixture = new();
|
||||
private readonly TagFixture _tagFixture = new();
|
||||
private readonly ReleaseInfoFixture _releaseInfoFixture = new();
|
||||
private readonly LanguageInfoFixture _languageInfoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="VideoMetadata"/>.
|
||||
/// </summary>
|
||||
/// <param name="title">Optional. The title of the video.</param>
|
||||
/// <param name="originalTitle">Optional. The original title of the video.</param>
|
||||
/// <param name="durationInSeconds">Optional. The duration of the video in seconds.</param>
|
||||
/// <param name="resolution">Optional. The resolution of the video.</param>
|
||||
/// <param name="description">Optional. The description of the video.</param>
|
||||
/// <param name="releaseInfo">Optional. The release information of the video.</param>
|
||||
/// <param name="language">Optional. The language of the video.</param>
|
||||
/// <param name="originalLanguage">Optional. The original language of the video.</param>
|
||||
/// <param name="frameRate">Optional. The frame rate of the video.</param>
|
||||
/// <param name="videoCodec">Optional. The video codec used.</param>
|
||||
/// <param name="audioCodec">Optional. The audio codec used.</param>
|
||||
/// <param name="genres">Optional. The genres of the video.</param>
|
||||
/// <param name="tags">Optional. The tags associated with the video.</param>
|
||||
/// <returns>The created <see cref="VideoMetadata"/>.</returns>
|
||||
public VideoMetadata Create(
|
||||
string? title = null,
|
||||
Optional<string>? originalTitle = null,
|
||||
int? durationInSeconds = null,
|
||||
string? resolution = null,
|
||||
Optional<string>? description = null,
|
||||
ReleaseInfo? releaseInfo = null,
|
||||
Optional<LanguageInfo>? language = null,
|
||||
Optional<LanguageInfo>? originalLanguage = null,
|
||||
Optional<float>? frameRate = null,
|
||||
Optional<string>? videoCodec = null,
|
||||
Optional<string>? audioCodec = null,
|
||||
List<Genre>? genres = null,
|
||||
List<Tag>? tags = null)
|
||||
{
|
||||
return VideoMetadata.Create(
|
||||
title ?? _faker.Commerce.ProductName(),
|
||||
originalTitle ?? Optional<string>.None(),
|
||||
durationInSeconds ?? _faker.Random.Int(60, 18000),
|
||||
resolution ?? "1920x1080",
|
||||
description ?? Optional<string>.Some(_faker.Lorem.Sentence()),
|
||||
releaseInfo ?? _releaseInfoFixture.Create(),
|
||||
language ?? Optional<LanguageInfo>.Some(_languageInfoFixture.Create()),
|
||||
originalLanguage ?? Optional<LanguageInfo>.None(),
|
||||
frameRate ?? Optional<float>.Some(24),
|
||||
videoCodec ?? Optional<string>.Some("H.264"),
|
||||
audioCodec ?? Optional<string>.Some("AAC"),
|
||||
genres ?? [_genreFixture.Create(), _genreFixture.Create()],
|
||||
tags ?? [_tagFixture.Create(), _tagFixture.Create()]).Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="VideoMetadata"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="VideoMetadata"/> instances.</returns>
|
||||
public List<VideoMetadata> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.TvShowLibraryAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.VideoLibraryBoundedContext.TvShowLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="EpisodeId"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class EpisodeIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="EpisodeId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The value used to create the <see cref="EpisodeId"/>. If not provided, a random value is generated.</param>
|
||||
/// <returns>The created <see cref="EpisodeId"/>.</returns>
|
||||
public EpisodeId Create(Guid? value = null)
|
||||
{
|
||||
return value is null ? EpisodeId.CreateUnique() : EpisodeId.Create(value.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="EpisodeId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="EpisodeId"/> instances.</returns>
|
||||
public List<EpisodeId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.TvShowLibraryAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.VideoLibraryBoundedContext.TvShowLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="SeasonId"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class SeasonIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="SeasonId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The value used to create the <see cref="SeasonId"/>. If not provided, a random value is generated.</param>
|
||||
/// <returns>The created <see cref="SeasonId"/>.</returns>
|
||||
public SeasonId Create(Guid? value = null)
|
||||
{
|
||||
return value is null ? SeasonId.CreateUnique() : SeasonId.Create(value.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="SeasonId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="SeasonId"/> instances.</returns>
|
||||
public List<SeasonId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.TvShowLibraryAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.VideoLibraryBoundedContext.TvShowLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="TvShowId"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class TvShowIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="TvShowId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The value used to create the <see cref="TvShowId"/>. If not provided, a random value is generated.</param>
|
||||
/// <returns>The created <see cref="TvShowId"/>.</returns>
|
||||
public TvShowId Create(Guid? value = null)
|
||||
{
|
||||
return value is null ? TvShowId.CreateUnique() : TvShowId.Create(value.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="TvShowId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="TvShowId"/> instances.</returns>
|
||||
public List<TvShowId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user