Ejemplo n.º 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>()));
        }
Ejemplo n.º 2
0
 public BagsController(SearchQueryHandler <Bag, Domain.Tea.Bag> searchBagsCommand,
                       GetQueryHandler <Bag, Domain.Tea.Bag> getBagType,
                       IAsyncCommandHandler <UpdateBagCommand> updateCommand,
                       IAsyncCommandHandler <CreateBagCommand> createCommand,
                       ITranslator <IQueryResult, IActionResult> queryTranslator,
                       ITranslator <ICommandResult, IActionResult> commandTranslator)
 {
     SearchBagsCommand = searchBagsCommand ?? throw new System.ArgumentNullException(nameof(searchBagsCommand));
     GetBagType        = getBagType ?? throw new System.ArgumentNullException(nameof(getBagType));
     UpdateCommand     = updateCommand ?? throw new System.ArgumentNullException(nameof(updateCommand));
     CreateCommand     = createCommand ?? throw new System.ArgumentNullException(nameof(createCommand));
     QueryTranslator   = queryTranslator ?? throw new System.ArgumentNullException(nameof(queryTranslator));
     CommandTranslator = commandTranslator ?? throw new System.ArgumentNullException(nameof(commandTranslator));
 }
Ejemplo n.º 3
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>()));
        }
 public CountriesController(SearchQueryHandler <Country, Domain.Tea.Country> searchCountriesCommand,
                            GetQueryHandler <Country, Domain.Tea.Country> getCountry,
                            IAsyncCommandHandler <UpdateCommand <Country>, Domain.Tea.Country> updateCommand,
                            IAsyncCommandHandler <CreateCommand <Country>, Domain.Tea.Country> createCommand,
                            IAsyncQueryHandler <SearchRefValuesQuery <Domain.Tea.Country> > searchRefValuesQuery,
                            ITranslator <IQueryResult, IActionResult> queryTranslator,
                            ITranslator <ICommandResult, IActionResult> commandTranslator)
 {
     SearchCountriesCommand = searchCountriesCommand ?? throw new System.ArgumentNullException(nameof(searchCountriesCommand));
     GetCountry             = getCountry ?? throw new System.ArgumentNullException(nameof(getCountry));
     UpdateCommand          = updateCommand ?? throw new System.ArgumentNullException(nameof(updateCommand));
     CreateCommand          = createCommand ?? throw new System.ArgumentNullException(nameof(createCommand));
     SearchRefValuesQuery   = searchRefValuesQuery ?? throw new System.ArgumentNullException(nameof(searchRefValuesQuery));
     QueryTranslator        = queryTranslator ?? throw new System.ArgumentNullException(nameof(queryTranslator));
     CommandTranslator      = commandTranslator ?? throw new System.ArgumentNullException(nameof(commandTranslator));
 }
Ejemplo n.º 5
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);
        }