mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 14:11:10 +00:00
Adds playlist management and playback
This commit is contained in:
1 parent
009a0c8156
commit
9889c86c76
296 files changed
+18830
-367
No files matched your search
+67
@@ -0,0 +1,67 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Events;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.Events;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.UnitTests.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="Playlist"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistTests
|
||||
{
|
||||
[Fact]
|
||||
public void Delete_WhenCalled_ShouldMarkThePlaylistAsDeletedAndRaiseOneEvent()
|
||||
{
|
||||
// Arrange
|
||||
Result<Playlist> createResult = Playlist.Create(
|
||||
UserId.Create(Guid.NewGuid()),
|
||||
"Playlist",
|
||||
Optional<string>.None(),
|
||||
PlaylistType.Music);
|
||||
Assert.False(createResult.IsFailure);
|
||||
Playlist playlist = createResult.Value;
|
||||
Assert.False(playlist.IsDeleted);
|
||||
|
||||
// Act
|
||||
Result<Deleted> result = playlist.Delete();
|
||||
List<IDomainEvent> domainEvents = playlist.GetDomainEvents();
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.True(playlist.IsDeleted);
|
||||
Assert.Single(domainEvents);
|
||||
Assert.IsType<PlaylistDeletedDomainEvent>(domainEvents[0]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Delete_WhenCalledAgain_ShouldNotRaiseAnotherEvent()
|
||||
{
|
||||
// Arrange
|
||||
Result<Playlist> createResult = Playlist.Create(
|
||||
UserId.Create(Guid.NewGuid()),
|
||||
"Playlist",
|
||||
Optional<string>.None(),
|
||||
PlaylistType.Music);
|
||||
Assert.False(createResult.IsFailure);
|
||||
Playlist playlist = createResult.Value;
|
||||
playlist.Delete();
|
||||
|
||||
// Act
|
||||
Result<Deleted> result = playlist.Delete();
|
||||
List<IDomainEvent> domainEvents = playlist.GetDomainEvents();
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.True(playlist.IsDeleted);
|
||||
Assert.Single(domainEvents);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user