Ejemplo n.º 1
0
        public async Task Get_episode_query_handler_should_pass()
        {
            // Arrange
            var episode = new EpisodeBuilder().Generate().SaveChanges(_testFixture.Context).Build().First();
            var query   = new GetEpisodeQuery {
                Id = episode.Id
            };
            var queryHandler = new GetEpisodeQueryHandler(_testFixture.Context, _testFixture.Mapper);

            // Act
            var response = await queryHandler.Handle(query, CancellationToken.None);

            // Assert
            response.Name.ShouldBe(episode.Name);
            response.ShouldBeOfType(typeof(EpisodeViewModel));
        }
Ejemplo n.º 2
0
        public async Task Get_episode_query_handler_should_throw_not_found_exception()
        {
            // Arrange
            var episode = new EpisodeBuilder().Generate().SaveChanges(_testFixture.Context).Build().First();
            var query   = new GetEpisodeQuery {
                Id = episode.Id + 1
            };
            var queryHandler = new GetEpisodeQueryHandler(_testFixture.Context, _testFixture.Mapper);

            // Act
            async Task Act() => await queryHandler.Handle(query, CancellationToken.None);

            var ex = await Record.ExceptionAsync(Act);

            // Assert
            ex.ShouldBeOfType <NotFoundException>();
        }