public async Task <IActionResult> RemoveMediaFromFavorites(string id)
        {
            var command = RemoveFavoriteMediaCommand.Create(id, User.GetUserId());
            await _mediator.Send(command);

            return(Ok());
        }
        public void GivenUserIdIsNull_ArgumentNullExceptionIsThrown()
        {
            var    givenSampleMediaInstanceId = "abcdefgh";
            string givenUserId = null;

            Action act = () => RemoveFavoriteMediaCommand.Create(givenSampleMediaInstanceId, givenUserId);

            act.Should().Throw <ArgumentNullException>();
        }
        public void GivenMediaInstanceIdIsNull_ArgumentNullExceptionIsThrown()
        {
            string givenMediaInstanceId = null;
            var    givenSampleUser      = "******";

            Action act = () => RemoveFavoriteMediaCommand.Create(givenMediaInstanceId, givenSampleUser);

            act.Should().Throw <ArgumentNullException>();
        }
        public void GivenNoMatchingFavoriteMediaInDatabase_NoActionIsDone()
        {
            var givenUserId                   = "user1";
            var givenMediaInstanceId          = "1";
            var givenDifferentMediaInstanceId = "2";

            AddMediaInstance(givenDifferentMediaInstanceId);
            AddFavoriteMedia(givenDifferentMediaInstanceId, givenUserId);

            var    command = RemoveFavoriteMediaCommand.Create(givenMediaInstanceId, givenUserId);
            var    handler = new RemoveFavoriteMediaCommandHandler(_contextMock);
            Action act     = () => handler.Handle(command, CancellationToken.None).Wait();

            act.Should().NotThrow <Exception>();
        }
        public void GivenDatabaseWithSingleFavoriteMedia_ThenFavoriteMediaTableIsEmpty()
        {
            var givenSampleUserId          = "user1";
            var givenSampleMediaInstanceId = "1";

            AddMediaInstance(givenSampleMediaInstanceId);
            AddFavoriteMedia(givenSampleMediaInstanceId, givenSampleUserId);

            var command = RemoveFavoriteMediaCommand.Create(givenSampleMediaInstanceId, givenSampleUserId);
            var handler = new RemoveFavoriteMediaCommandHandler(_contextMock);

            handler.Handle(command, CancellationToken.None).Wait();

            _contextMock.FavoriteMedia.Should().BeEmpty();
        }