Exemple #1
0
        private static CountriesByContinentIdAndLanguageIdQuery Query()
        {
            var providerMock = new Mock <IQueryDispatcher>();

            var query = new CountriesByContinentIdAndLanguageIdQuery(providerMock.Object);

            return(query);
        }
        public void HandleAsync_Return_Task_Of_IEnumerable_Of_CountryItem()
        {
            //Arrange
            var handler      = Handler();
            var providerMock = new Mock <IQueryDispatcher>();
            var query        = new CountriesByContinentIdAndLanguageIdQuery(providerMock.Object);

            //Act
            var result = handler.HandleAsync(query);

            //Assert
            Assert.IsInstanceOf <Task <IEnumerable <CountryItem> > >(result);
        }
Exemple #3
0
        protected IQueryable <CountryItem> ProjectionToCountryItems(IQueryable <Country> source, CountriesByContinentIdAndLanguageIdQuery query)
        {
            var regions = source.Select(p => p.Region);

            var countriesOfContinent =
                regions.SelectMany(p => p.ToChildRegions).Where(p => p.ToId == query.ContinentId).Select(p => p.Id);

            var localizedRegions =
                regions.Where(p => countriesOfContinent.Contains(p.Id)).SelectMany(p => p.LocalizedRegions).Where(p => p.LanguageId == query.LanguageId);

            return(ProjectTo <CountryItem>(localizedRegions));
        }
Exemple #4
0
 public override async Task <IEnumerable <CountryItem> > HandleAsync(CountriesByContinentIdAndLanguageIdQuery query, CancellationToken cancellationToken)
 {
     return(await ProjectionToCountryItems(Source, query).ToArrayAsync(cancellationToken));
 }