Exemple #1
0
        public async Task Handle_GivenNullRequest_ShouldThrowArgumentNullException()
        {
            // Arrange
            var sut = new SearchQueryHandler(
                It.IsAny <IDeletableEntityRepository <Player> >(),
                It.IsAny <IDeletableEntityRepository <Team> >(),
                It.IsAny <IDeletableEntityRepository <Tournament> >(),
                It.IsAny <IMapper>());

            // Act & Assert
            await Should.ThrowAsync <ArgumentNullException>(sut.Handle(null, It.IsAny <CancellationToken>()));
        }
Exemple #2
0
        public async Task Handle_GivenInvalidRequest_ShouldThrowInvalidSearchQueryException()
        {
            // Arrange
            var query = new SearchQuery {
                Query = string.Empty
            };

            var teamsRepository       = new EfDeletableEntityRepository <Team>(this.dbContext);
            var tournamentsRepository = new EfDeletableEntityRepository <Tournament>(this.dbContext);

            var sut = new SearchQueryHandler(this.deletableEntityRepository, teamsRepository, tournamentsRepository, this.mapper);

            // Act & Assert
            await Should.ThrowAsync <InvalidSearchQueryException>(sut.Handle(query, It.IsAny <CancellationToken>()));
        }
Exemple #3
0
        public async Task Handle_GivenValidRequest_ShouldReturnValidPlayerSearchQueryResults()
        {
            // Arrange
            var query = new SearchQuery {
                Query = "FooP1"
            };

            var teamsRepository       = new EfDeletableEntityRepository <Team>(this.dbContext);
            var tournamentsRepository = new EfDeletableEntityRepository <Tournament>(this.dbContext);

            var sut = new SearchQueryHandler(this.deletableEntityRepository, teamsRepository, tournamentsRepository, this.mapper);

            // Act
            var viewModel = await sut.Handle(query, It.IsAny <CancellationToken>());

            // Arrange
            viewModel.ShouldNotBeNull();
            viewModel.Players.Count().ShouldBe(1);
        }