public void get_active_play_lists() { var aPlayListId = APlaylist.Id; var aPlayListName = APlaylist.Name; var aPlayListImageUrl = APlaylist.ImageUrl; var aPlayList = new PlayListBuilder() .WithId(aPlayListId) .WithName(aPlayListName) .WithImageUrl(aPlayListImageUrl) .WithStatus(PlayListStatus.Active) .AddTrack(new TrackBuilder() .WithId(ATrack.Id) .WithName(ATrack.Name) .WithArtist(ATrack.Artist) .WithDuration(ATrack.DurationInMs) .Build()) .Build(); var anotherPlayListId = APlaylist.AnotherId; var anotherPlayList = new PlayListBuilder() .WithId(anotherPlayListId) .WithStatus(PlayListStatus.Archived) .Build(); playListQuery.GetAllPlayList().Returns(new List <PlayList> { aPlayList, anotherPlayList }); var result = getAllPlayListQuery.Execute(); result.IsRight.Should().BeTrue(); result.IfRight(listOfPlayLists => VerifyAreEquivalent(listOfPlayLists, aPlayList)); }
public void add_an_image_url_to_a_play_list() { var aPlaylistId = APlaylist.Id; var aPlayList = new PlayListBuilder() .WithId(aPlaylistId) .Build(); playListPersistence.GetPlayList(aPlaylistId).Returns(aPlayList); var anImageUrl = APlaylist.AnotherImageUrl; var result = addImageUrlToPlayListService.Execute(aPlaylistId, anImageUrl); result.IsRight.Should().BeTrue(); VerifyPlayListHasBeenPersistedWith(aPlaylistId, anImageUrl); playListNotifier.Received().NotifyPlayListUrlHasChanged(aPlaylistId, anImageUrl); }
public void archive_a_play_list() { var aPlaylistId = APlaylist.Id; var aPlayList = new PlayListBuilder() .WithId(aPlaylistId) .WithStatus(PlayListStatus.Active) .Build(); playListPersistence.GetPlayList(aPlaylistId).Returns(aPlayList); var result = archivePlayListService.Execute(aPlaylistId); result.IsRight.Should().BeTrue(); VerifyPlayListHasBeenPersistedWith(aPlaylistId, PlayListStatus.Archived); playListNotifier.Received().NotifyPlayListHasBeenArchived(aPlaylistId); }
public void add_a_track_to_a_play_list() { var aTrackId = ATrack.Id; var aPlaylistId = APlaylist.Id; var aPlayList = new PlayListBuilder() .WithId(aPlaylistId) .Build(); playListPersistence.GetPlayList(aPlaylistId).Returns(aPlayList); var result = addTrackToPlayListService.Execute(aTrackId, aPlaylistId); result.IsRight.Should().BeTrue(); VerifyPlayListHasBeenPersistedWith(aPlaylistId, aTrackId); VerifyEventHasBeenRaised(new TrackHasBeenAddedToPlayList(aTrackId, aPlaylistId), eventPublisher); }
public void do_not_remove_a_track_when_it_is_not_already_in_the_play_list() { var aTrackId = ATrack.Id; var aPlaylistId = APlaylist.Id; var aPlayList = new PlayListBuilder() .WithId(aPlaylistId) .Build(); playListPersistence.GetPlayList(aPlaylistId).Returns(aPlayList); var result = removeTrackFromPLayListService.Execute(aTrackId, aPlaylistId); result.IsLeft.Should().BeTrue(); result.IfLeft(error => error.Should().Be(DomainError.TrackIsNotInThePlayList)); playListPersistence.DidNotReceive().Persist(Arg.Any <PlayList>()); eventPublisher.DidNotReceive().Publish(Arg.Any <List <Event> >()); }
public void change_play_list_name() { var aPlaylistId = APlaylist.Id; var aPlaylistName = APlaylist.Name; var aPlayList = new PlayListBuilder() .WithId(aPlaylistId) .WithName(aPlaylistName) .Build(); playListPersistence.GetPlayList(aPlaylistId).Returns(aPlayList); var anotherPlaylistName = APlaylist.AnotherName; var result = renamePlayListService.Execute(aPlaylistId, anotherPlaylistName); result.IsRight.Should().BeTrue(); VerifyPlayListHasBeenPersistedWith(aPlaylistId, anotherPlaylistName); }
public void archive_a_play_list() { var aPlaylistId = APlaylist.Id; var aPlayList = new PlayListBuilder() .WithId(aPlaylistId) .WithStatus(PlayListStatus.Active) .Build(); playListPersistence.GetPlayList(aPlaylistId).Returns(aPlayList); var command = new ArchivePlayList(aPlaylistId); var result = archivePlayListCommandHandler.Handle(command); result.IsRight.Should().BeTrue(); VerifyPlayListHasBeenPersistedWith(aPlaylistId, PlayListStatus.Archived); VerifyEventHasBeenRaised(new PlayListHasBeenArchived(aPlaylistId), eventPublisher); }
public void add_an_image_url_to_a_play_list() { var aPlaylistId = APlaylist.Id; var aPlayList = new PlayListBuilder() .WithId(aPlaylistId) .Build(); playListPersistence.GetPlayList(aPlaylistId).Returns(aPlayList); var anImageUrl = APlaylist.AnotherImageUrl; var command = new ChangePlayListImageUrl(aPlaylistId, anImageUrl); var result = addImageUrlToPlayListCommandHandler.Handle(command); result.IsRight.Should().BeTrue(); VerifyPlayListHasBeenPersistedWith(aPlaylistId, anImageUrl); VerifyEventHasBeenRaised(new PlayListImageUrlHasChanged(aPlaylistId, anImageUrl), eventPublisher); }
public void remove_an_existing_track_from_a_play_list() { var aTrackId = ATrack.Id; var aPlaylistId = APlaylist.Id; var aPlayList = new PlayListBuilder() .WithId(aPlaylistId) .AddTrack(new TrackBuilder() .WithId(aTrackId) .Build()) .Build(); playListPersistence.GetPlayList(aPlaylistId).Returns(aPlayList); var result = removeTrackFromPLayListService.Execute(aTrackId, aPlaylistId); result.IsRight.Should().BeTrue(); VerifyAnEmptyPlayListHasBeenPersistedWith(aPlaylistId); VerifyEventHasBeenRaised(new TrackHasBeenRemovedFromPlayList(aTrackId, aPlaylistId), eventPublisher); }
public void do_not_add_a_track_twice() { var aTrackId = ATrack.Id; var aPlaylistId = APlaylist.Id; var aPlayList = new PlayListBuilder() .WithId(aPlaylistId) .AddTrack(new TrackBuilder() .WithId(aTrackId) .Build()) .Build(); playListPersistence.GetPlayList(aPlaylistId).Returns(aPlayList); var result = addTrackToPlayListService.Execute(aTrackId, aPlaylistId); result.IsLeft.Should().BeTrue(); result.IfLeft(error => error.Should().Be(DomainError.CannotAddSameTrackTwice)); playListPersistence.DidNotReceive().Persist(Arg.Any <PlayList>()); eventPublisher.DidNotReceive().Publish(Arg.Any <List <Event> >()); }