public async Task <IActionResult> GetById(int id)
        {
            var movieGetByIdQuery = new MovieGetByIdQuery {
                Id = id
            };

            return(HandleQuery <Movie, MoviesGetByIdViewModel>(await _mediator.Send(movieGetByIdQuery)));
        }
        public async Task Handler_Returns_Movie_When_User_Id_Is_Missing()
        {
            await InitializeRecords();

            var query = new MovieGetByIdQuery(_testQuery.Id, null);

            var result = await _handler.Handle(query);

            result.Should().NotBeNull();
        }
Esempio n. 3
0
        public async Task <Response <Exception, Movie> > Handle(MovieGetByIdQuery request, CancellationToken cancellationToken)
        {
            var movieCallback = await _movieRepository.GetByIdAsync(request.Id);

            if (movieCallback.HasError)
            {
                return(movieCallback.Error);
            }

            return(movieCallback.Success);
        }
        public MovieGetByIdQueryHandlerTests()
        {
            _fixture = new Fixture();
            _fixture.Behaviors.Add(new OmitOnRecursionBehavior());

            _context = InitializeDatabase();

            _testQuery = _fixture.Create <MovieGetByIdQuery>();

            _handler = new MovieGetByIdQueryHandler(_context);
        }