Ejemplo n.º 1
0
        public void ShouldRequireMinimumFields()
        {
            var command = new CreateMovieCommand();

            FluentActions.Invoking(() =>
                                   SendAsync(command)).Should().Throw <ValidationException>();
        }
 public static DomainMovie ConvertToDomain(this CreateMovieCommand movie)
 {
     return(DomainMovie.Create(
                movie.Title,
                movie.Description,
                DomainGenre.Get(movie.Genre),
                movie.YearReleased));
 }
        public void DadoUmFilmeSemNome_Invalid()
        {
            var command = new CreateMovieCommand("");

            command.Validate();

            Assert.AreEqual(command.Invalid, true);
        }
        public void DadoUmFilmeValido_Valid()
        {
            var command = new CreateMovieCommand("Nome do Filme");

            command.Validate();

            Assert.AreEqual(command.Valid, true);
        }
Ejemplo n.º 5
0
 public MoviesController()
 {
     _createMovieCommand = new CreateMovieCommand();
     _deleteMovieCommand = new DeleteMovieCommand();
     _getAllMoviesQuery  = new GetAllMoviesQuery();
     _searchMoviesQuery  = new SearchMoviesQuery();
     _editMovieCommand   = new EditMovieCommand();
 }
        public void DadoUmFilmeValido_Valid()
        {
            var command = new CreateMovieCommand("Novo Filme");

            var handler = new CreateMovieHandler(new FakeRepositoryMovie());
            var result  = handler.Handle(command).Result;

            Assert.AreEqual(true, result.Success);
        }
        public void DadoUmFilmeJaCadastrado_Invalid()
        {
            var command = new CreateMovieCommand("CADASTRADO");

            var handler = new CreateMovieHandler(new FakeRepositoryMovie());
            var result  = handler.Handle(command).Result;

            Assert.AreEqual(false, result.Success);
        }
Ejemplo n.º 8
0
        public async Task ShouldRequireUniqueTitle()
        {
            await SendAsync(new CreateMovieCommand
            {
                Title = "Shopping"
            });

            var command = new CreateMovieCommand
            {
                Title = "Shopping"
            };

            FluentActions.Invoking(() =>
                                   SendAsync(command)).Should().Throw <ValidationException>();
        }
Ejemplo n.º 9
0
        public async Task ShouldCreateTodoList()
        {
            var userId = await RunAsDefaultUserAsync();

            var command = new CreateMovieCommand
            {
                Title = "Tasks"
            };

            var id = await SendAsync(command);

            var list = await FindAsync <Movie>(id);

            list.Should().NotBeNull();
            list.Title.Should().Be(command.Title);
            list.CreatedBy.Should().Be(userId);
            list.Created.Should().BeCloseTo(DateTime.Now, 10000);
        }
Ejemplo n.º 10
0
        public async Task <IActionResult> Create([FromBody] CreateMovieCommand command)
        {
            try
            {
                var result = await _handler.Handle(command);

                if (command.Notifications.Any())
                {
                    return(BadRequest(result));
                }

                return(Ok(result));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 11
0
        public IActionResult CreateMovie([FromBody] Movie movie)
        {
            if (movie == null)
            {
                return(NotFound());
            }

            var command = new CreateMovieCommand(movie);

            DomainDispatcher.ExecuteCommand(command);

            if (command.WasSuccesful)
            {
                return(Ok());
            }
            else
            {
                return(BadRequest());
            }
        }
        public CreateMovieResult CreateMovie(CreateMovieCommand movie)
        {
            var entity = new Movie
            {
                Title       = movie.Title,
                ReleaseDate = movie.ReleaseDate,
                Genre       = movie.Genre,
                Price       = movie.Price,
                Rating      = movie.Rating,
                DirectorID  = movie.DirectorID
            };

            _movieRepo.Create(entity);
            _movieRepo.SaveChanges();

            return(new CreateMovieResult
            {
                ID = entity.ID
            });
        }
Ejemplo n.º 13
0
        public IActionResult Create()
        {
            var command = new CreateMovieCommand();

            command.Title       = "Title";
            command.Budget      = 2154594;
            command.Salary      = 4525487;
            command.ImagePath   = "ImagePath";
            command.Description = "Description";
            command.ReleaseDate = DateTime.Now;
            command.DirectorId  = 1;
            command.Genres      = new List <int> {
                1, 2
            };
            command.ActorIds = new List <int> {
                1, 2
            };

            _commandExecutor.Execute(command);
            return(View(command));
        }
Ejemplo n.º 14
0
        public async Task CreateMovieCommandHandlerTest()
        {
            var userId = await RunAsDefaultUserAsync();

            var command = new CreateMovieCommand
            {
                Name        = "Movie test",
                Description = "Movie test description",
                Duration    = 120
            };

            var id = await SendAsync(command);

            var list = await FindAsync <Movie>(id);

            list.Should().NotBeNull();
            list.Name.Should().Be(command.Name);
            list.Description.Should().Be(command.Description);
            list.Name.Should().Be(command.Name);
            list.Duration.Should().Be(command.Duration);
        }
Ejemplo n.º 15
0
 public CreateMovieStatus Create(CreateMovieCommand command)
 {
     return((CreateMovieStatus)CommandBus.Execute(command));
 }
 public IActionResult InsertMovie(CreateMovieCommand command)
 {
     return(View());
 }
Ejemplo n.º 17
0
 public async Task <ActionResult <int> > Create(CreateMovieCommand command)
 {
     return(await Mediator.Send(command));
 }
        public async Task <ActionResult <MovieResponse> > CreateMovie([FromBody] CreateMovieCommand command)
        {
            var result = await _mediator.Send(command);

            return(Ok(result));
        }
Ejemplo n.º 19
0
 public async Task <IActionResult> SaveNewGenre(CreateMovieCommand command)
 {
     return(Ok(await Mediator.Send(command)));
 }
Ejemplo n.º 20
0
        public async Task <ActionResult <int> > Create([FromBody] CreateMovieCommand command)
        {
            var movieId = await _mediator.Send(command);

            return(Ok(movieId));
        }
        public async Task <IActionResult> Post([FromBody] CreateMovieCommand command)
        {
            var id = await _mediator.Send(command);

            return(CreatedAtAction(nameof(GetById), new { id = id }, command));
        }