Ejemplo n.º 1
0
        public async Task <IEnumerable <TournamentFormatSelectItemLookupModel> > Handle(
            GetAllTournamentFormatsSelectListQuery request,
            CancellationToken cancellationToken)
        {
            request = request ?? throw new ArgumentNullException(nameof(request));

            var lookups = await this.tournamentFormatsRepository
                          .AllAsNoTracking()
                          .ProjectTo <TournamentFormatSelectItemLookupModel>(this.mapper.ConfigurationProvider)
                          .ToListAsync(cancellationToken);

            return(lookups);
        }
        public async Task Handle_GivenValidRequest_ShouldReturnIEnumerable()
        {
            // Arrange
            var query = new GetAllTournamentFormatsSelectListQuery();
            var sut   = new GetAllTournamentFormatsSelectListQueryHandler(this.deletableEntityRepository, this.mapper);

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

            // Assert
            viewModel.ShouldNotBeNull();
            viewModel.ShouldBeAssignableTo <IEnumerable <TournamentFormatSelectItemLookupModel> >();
            viewModel.Count().ShouldBe(2);
        }