public void Should_return_unsuccessful_command_result_when_movie_command_is_invalid()
        {
            var command = new MoviesCommand();
            var result  = this.handler.Handle(command);

            result.Should().BeAssignableTo <UnsuccessfulCommandResult>();
        }
        public void Should_contains_a_notification_when_movie_list_is_null()
        {
            var command = new MoviesCommand();

            command.Validate();

            command.Notifications.Should().ContainSingle();
        }
        public void Should_contain_any_notification_in_when_return_unsuccessful_command_result()
        {
            var command       = new MoviesCommand();
            var result        = this.handler.Handle(command);
            var notifications = (List <Notification>)result.Data;

            notifications.Should().HaveCountGreaterOrEqualTo(1);
        }
        public void Should_contain_a_notification_when_movie_list_contain_less_of_quantity_required_items()
        {
            var command = new MoviesCommand()
            {
                Movies = new List <MovieCommand>()
            };

            command.Validate();

            command.Notifications.Should().ContainSingle();
        }
        public void Should_return_successful_command_result_when_movie_command_is_valid()
        {
            var movies  = JsonConvert.DeserializeObject <List <MovieCommand> >(MoviesMock.RegularCase);
            var command = new MoviesCommand();

            movies.ForEach(movie => command.Movies.Add(movie));

            var result = this.handler.Handle(command);

            result.Should().BeAssignableTo <SuccessfulCommandResult>();
        }
        public void Should_contain_winners_in_successful_command_result()
        {
            var movies  = JsonConvert.DeserializeObject <List <MovieCommand> >(MoviesMock.RegularCase);
            var command = new MoviesCommand();

            movies.ForEach(movie => command.Movies.Add(movie));

            var result = this.handler.Handle(command);

            var winners = (List <Movie>)result.Data;

            winners.Should().HaveCount(2);
        }
        public void Should_not_contain_a_notification_when_movie_list_is_valid()
        {
            var movies = new List <MovieCommand>();

            for (var i = 0; i < MoviesCommand.REQUIRED_QUANTITY_MOVIES; i++)
            {
                movies.Add(new MovieCommand()
                {
                    Id    = this.fixture.Create <string>(),
                    Title = this.fixture.Create <string>(),
                    Year  = this.fixture.Create <int>(),
                    Score = this.fixture.Create <int>(),
                });
            }

            var command = new MoviesCommand()
            {
                Movies = movies
            };

            command.Validate();

            command.Notifications.Should().BeEmpty();
        }
        public void Should_contain_a_notification_when_movie_list_contain_more_of_quantity_required_items()
        {
            var movies = new List <MovieCommand>();

            for (var i = 0; i < MoviesCommand.REQUIRED_QUANTITY_MOVIES + 1; i++)
            {
                movies.Add(new MovieCommand()
                {
                    Id    = MockString(),
                    Title = MockString(),
                    Year  = this.fixture.Create <int>(),
                    Score = this.fixture.Create <int>(),
                });
            }

            var command = new MoviesCommand()
            {
                Movies = movies
            };

            command.Validate();

            command.Notifications.Should().ContainSingle();
        }
示例#9
0
        public ActionResult <IEnumerable <MovieCommand> > Post([FromBody] MoviesCommand moviesCommand)
        {
            var result = this.handler.Handle(moviesCommand);

            return(this.StatusCode((int)result.StatusCode, result));
        }