Exemplo n.º 1
0
        public void Instance_Implement_Interface_IQuery_Of_IEnumerable_Of_Attributes()
        {
            //Arrange
            var type         = typeof(IQuery <IEnumerable <Data.Transfer.Object.Attribute> >);
            var providerMock = new Mock <IProvider>();

            //Act
            var query = new GetAttributesByAccommodationIdAndLanguageId(providerMock.Object);

            //Assert
            Assert.IsInstanceOf(type, query);
        }
Exemplo n.º 2
0
        public void Instance_Implement_Interface_IHaveLanguageId_Of_Integer()
        {
            //Arrange
            var type         = typeof(IHaveLanguageId <int>);
            var providerMock = new Mock <IProvider>();

            //Act
            var query = new GetAttributesByAccommodationIdAndLanguageId(providerMock.Object);

            //Assert
            Assert.IsInstanceOf(type, query);
        }
        public void HandleAsync()
        {
            //Arrange
            var ownerMock     = new Mock <IHaveGlobalizationQueryable <AccommodationToAttribute> >();
            var projectorMock = new Mock <IProjection>();

            var handler = new AttributesByAccommodationIdAndLanguageId(ownerMock.Object, projectorMock.Object);

            var providerMock = new Mock <IProvider>();
            var query        = new GetAttributesByAccommodationIdAndLanguageId(providerMock.Object);

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

            //Assert
            Assert.IsInstanceOf <Task <IEnumerable <Attribute> > >(result);
        }
Exemplo n.º 4
0
        protected IQueryable <Attribute> ProjectionToAttribute(IQueryable <AccommodationToAttribute> accommodationsToAttributes, GetAttributesByAccommodationIdAndLanguageId query, IProjection projector)
        {
            accommodationsToAttributes = accommodationsToAttributes
                                         .Include(p => p.Attribute)
                                         .Include(p => p.Attribute.LocalizedAttributes)
                                         .Where(p => p.AccommodationId == query.AccommodationId)
                                         .Where(p => p.LanguageId == query.LanguageId)
                                         .OrderBy(p => p.Attribute.Ban)
            ;

            return(projector.ProjectTo <Attribute>(accommodationsToAttributes));
        }
Exemplo n.º 5
0
 public override async Task <IEnumerable <Attribute> > HandleAsync(GetAttributesByAccommodationIdAndLanguageId query, CancellationToken cancellationToken)
 {
     return(await ProjectionToAttribute(Source, query, Projector).ToArrayAsync(cancellationToken));
 }