Пример #1
0
        public async Task EventAggregators()
        {
            var aggregatorDto = new EventAggregatorDto {
                EventHandlerId       = 800,
                Destination          = AggregatorDestination.EventSubscriptionState,
                EventParameterNumber = 2,
                Operation            = AggregatorOperation.Sum,
                OutputKey            = "SumOfSomething",
                Source    = AggregatorSource.EventParameter,
                SourceKey = "Value"
            };

            await Fixture.ConfigRepo.EventAggregators.UpsertAsync(aggregatorDto);

            var fromRepo = await Fixture.ConfigRepo.EventAggregators.GetAsync(aggregatorDto.EventHandlerId);

            Assert.Equal(aggregatorDto.Destination, fromRepo.Destination);
            Assert.Equal(aggregatorDto.EventParameterNumber, fromRepo.EventParameterNumber);
            Assert.Equal(aggregatorDto.Operation, fromRepo.Operation);
            Assert.Equal(aggregatorDto.OutputKey, fromRepo.OutputKey);
            Assert.Equal(aggregatorDto.Source, fromRepo.Source);
            Assert.Equal(aggregatorDto.SourceKey, fromRepo.SourceKey);
        }
        public async Task Aggregate()
        {
            var config = new EventHandlerDto
            {
                Id = 50,
                EventSubscriptionId = 99,
                HandlerType         = EventHandlerType.Aggregate
            };

            var aggregateConfig = new EventAggregatorDto();

            _eventAggregatorConfigurationFactory
            .Setup(f => f.GetAsync(config.Id))
            .ReturnsAsync(aggregateConfig);

            var handler = await _eventHandlerFactory.LoadAsync(_mockEventSubscription.Object, config);

            var aggregator = handler as EventAggregator;

            Assert.NotNull(aggregator);
            Assert.Equal(config.Id, aggregator.Id);
            Assert.Same(_mockEventSubscription.Object, aggregator.Subscription);
            Assert.Same(aggregateConfig, aggregator.Configuration);
        }
 public EventAggregatorDto Add(EventAggregatorDto dto)
 {
     EventAggregators.Add(dto);
     return(dto);
 }