mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 13:11:10 +00:00
Refactors the book, artist, and album slices across the stack
This commit is contained in:
1 parent
8aaf9fe64e
commit
ea6eb9f796
439 files changed
+28235
-3156
No files matched your search
+51
-13
@@ -1,9 +1,10 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.ExternalIdentifiers.MediaContributorBoundedContext.MediaContributorAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -18,7 +19,6 @@ namespace Lumina.Domain.UnitTests.Core.BoundedContexts.WrittenContentLibraryBoun
|
||||
public class BookTests
|
||||
{
|
||||
private readonly BookFixture _bookFixture = new();
|
||||
private readonly MediaContributorIdFixture _mediaContributorIdFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenCalledWithValidData_ShouldCreateBook()
|
||||
@@ -38,16 +38,16 @@ public class BookTests
|
||||
{
|
||||
// Arrange
|
||||
Book book = _bookFixture.Create();
|
||||
MediaContributorId firstContributorId = _mediaContributorIdFixture.Create();
|
||||
MediaContributorId secondContributorId = _mediaContributorIdFixture.Create();
|
||||
BookMediaContributor firstContributor = CreateAuthorContributor();
|
||||
BookMediaContributor secondContributor = CreateAuthorContributor();
|
||||
|
||||
// Act
|
||||
book.UpdateContributors([firstContributorId, secondContributorId]);
|
||||
book.UpdateContributors([firstContributor, secondContributor]);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(2, book.Contributors.Count);
|
||||
Assert.Contains(book.Contributors, contributorId => contributorId == firstContributorId);
|
||||
Assert.Contains(book.Contributors, contributorId => contributorId == secondContributorId);
|
||||
Assert.Contains(book.Contributors, contributor => contributor == firstContributor);
|
||||
Assert.Contains(book.Contributors, contributor => contributor == secondContributor);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -55,16 +55,45 @@ public class BookTests
|
||||
{
|
||||
// Arrange
|
||||
Book book = _bookFixture.Create();
|
||||
book.UpdateContributors([_mediaContributorIdFixture.Create()]);
|
||||
MediaContributorId replacementContributorId = _mediaContributorIdFixture.Create();
|
||||
book.UpdateContributors([CreateAuthorContributor()]);
|
||||
BookMediaContributor replacementContributor = CreateAuthorContributor();
|
||||
|
||||
// Act
|
||||
book.UpdateContributors([replacementContributorId]);
|
||||
book.UpdateContributors([replacementContributor]);
|
||||
|
||||
// Assert
|
||||
// the previous contributors are replaced, not appended
|
||||
MediaContributorId contributorId = Assert.Single(book.Contributors);
|
||||
Assert.Equal(replacementContributorId, contributorId);
|
||||
BookMediaContributor contributor = Assert.Single(book.Contributors);
|
||||
Assert.Equal(replacementContributor, contributor);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenContributorsContainDuplicates_ShouldKeepOnlyUniqueContributors()
|
||||
{
|
||||
// Arrange
|
||||
BookMediaContributor contributor = CreateAuthorContributor();
|
||||
|
||||
// Act
|
||||
Book book = _bookFixture.Create(contributors: [contributor, contributor]);
|
||||
|
||||
// Assert
|
||||
BookMediaContributor storedContributor = Assert.Single(book.Contributors);
|
||||
Assert.Equal(contributor, storedContributor);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UpdateContributors_WhenCalledWithDuplicates_ShouldKeepOnlyUniqueContributors()
|
||||
{
|
||||
// Arrange
|
||||
Book book = _bookFixture.Create();
|
||||
BookMediaContributor contributor = CreateAuthorContributor();
|
||||
|
||||
// Act
|
||||
book.UpdateContributors([contributor, contributor]);
|
||||
|
||||
// Assert
|
||||
BookMediaContributor storedContributor = Assert.Single(book.Contributors);
|
||||
Assert.Equal(contributor, storedContributor);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -229,4 +258,13 @@ public class BookTests
|
||||
Assert.False(hasMetadataProvider);
|
||||
Assert.False(hasCoverImagePath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="BookMediaContributor"/> of a random media contributor playing the Author role.
|
||||
/// </summary>
|
||||
/// <returns>The created <see cref="BookMediaContributor"/>.</returns>
|
||||
private static BookMediaContributor CreateAuthorContributor()
|
||||
{
|
||||
return BookMediaContributor.Create(MediaContributorId.CreateUnique(), MediaContributorRole.Author).Value;
|
||||
}
|
||||
}
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Services;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.UnitTests.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="BookLibraryService"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BookLibraryServiceTests
|
||||
{
|
||||
[Fact]
|
||||
public void Books_WhenAccessed_ShouldThrowNotImplementedException()
|
||||
{
|
||||
// Arrange
|
||||
BookLibraryService sut = new();
|
||||
|
||||
// Act & Assert
|
||||
Assert.Throws<NotImplementedException>(() => sut.Books);
|
||||
}
|
||||
}
|
||||
-72
@@ -1,72 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.UnitTests.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="BookLibraryId"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BookLibraryIdTests
|
||||
{
|
||||
private readonly BookLibraryIdFixture _bookLibraryIdFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void CreateUnique_WhenCalled_ShouldReturnIdWithNonEmptyValue()
|
||||
{
|
||||
// Act
|
||||
Result<BookLibraryId> result = BookLibraryId.CreateUnique();
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotEqual(default, result.Value.Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenCalledWithValue_ShouldReturnIdWithThatValue()
|
||||
{
|
||||
// Arrange
|
||||
Guid value = Guid.NewGuid();
|
||||
|
||||
// Act
|
||||
Result<BookLibraryId> result = BookLibraryId.Create(value);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(value, result.Value.Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Equals_WithSameValue_ShouldReturnTrue()
|
||||
{
|
||||
// Arrange
|
||||
Guid value = Guid.NewGuid();
|
||||
BookLibraryId firstId = _bookLibraryIdFixture.Create(value);
|
||||
BookLibraryId secondId = _bookLibraryIdFixture.Create(value);
|
||||
|
||||
// Act
|
||||
bool result = firstId.Equals(secondId);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Equals_WithDifferentValue_ShouldReturnFalse()
|
||||
{
|
||||
// Arrange
|
||||
BookLibraryId firstId = _bookLibraryIdFixture.Create();
|
||||
BookLibraryId secondId = _bookLibraryIdFixture.Create();
|
||||
|
||||
// Act
|
||||
bool result = firstId.Equals(secondId);
|
||||
|
||||
// Assert
|
||||
Assert.False(result);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user