public Either <DomainError, CommandResult> Handle(ChangePlayListImageUrl command)
        {
            var playList = playListPersistence.GetPlayList(command.PlaylistId);

            playList.AddImageUrl(command.NewImageUrl);

            playListPersistence.Persist(playList);
            eventPublisher.Publish(playList.Events());
            return(CommandResult.Success);
        }
        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);
        }
Exemplo n.º 3
0
        public Either <DomainError, CommandResult> Process(ChangePlayListImageUrl command)
        {
            var commandHandler = playListCommandHandlerCreator.CreateAddImageUrlPlayListCommandHandler();

            return(commandHandler.Handle(command));
        }