Example #1
0
        public void ProviderCreatesCorrectMatchers(MatchType matchConfiguration, Type eventMatcherType)
        {
            var eventMatcherFactory = new EventMatcherFactory();

            var eventMatcher = eventMatcherFactory.GetEventMatcher(
                new EventMatchConfiguration
            {
                Type = matchConfiguration
            });

            Assert.Equal(eventMatcherType, eventMatcher.GetType());
        }
Example #2
0
        private async Task <EventSubscription> LoadEventSubscriptionsAsync(IEventSubscriptionDto subscriptionConfig)
        {
            var matcher = await EventMatcherFactory.LoadAsync(subscriptionConfig).ConfigureAwait(false);

            var state = await ConfigurationRepository.EventSubscriptionStates.GetAsync(subscriptionConfig.Id).ConfigureAwait(false);

            var handlerCoOrdinator = new EventHandlerManager(ConfigurationRepository.EventHandlerHistoryRepo);

            var subscription = new EventSubscription(
                subscriptionConfig.Id, subscriptionConfig.SubscriberId, matcher, handlerCoOrdinator, state);

            await AddEventHandlers(subscription).ConfigureAwait(false);

            return(subscription);
        }
Example #3
0
        public EventMatcherFactoryTest()
        {
            _mockParameterConditionRepository       = new Mock <IParameterConditionRepository>();
            _mockEventSubscriptionAddressRepository = new Mock <IEventSubscriptionAddressRepository>();
            _mockSubscriberContractRepository       = new Mock <ISubscriberContractRepository>();

            _factory = new EventMatcherFactory(
                _mockParameterConditionRepository.Object,
                _mockEventSubscriptionAddressRepository.Object,
                _mockSubscriberContractRepository.Object);

            _subscriberOneConfig = new SubscriberDto {
                Id = 1
            };
            _contractDto = new SubscriberContractDto
            {
                Id           = 1,
                SubscriberId = _subscriberOneConfig.Id,
                Abi          = TestData.Contracts.StandardContract.Abi,
                Name         = "Transfer"
            };
            _eventSubscriptionConfig = new EventSubscriptionDto
            {
                Id              = 1,
                SubscriberId    = _subscriberOneConfig.Id,
                ContractId      = _contractDto.Id,
                EventSignatures = new[] { TestData.Contracts.StandardContract.TransferEventSignature }.ToList()
            };
            _addressesConfig = new EventSubscriptionAddressDto
            {
                Id                  = 1,
                Address             = "",
                EventSubscriptionId = _eventSubscriptionConfig.Id
            };
            _parameterConditionConfig = new ParameterConditionDto
            {
                Id = 1,
                EventSubscriptionId = _eventSubscriptionConfig.Id,
                ParameterOrder      = 1,
                Operator            = ParameterConditionOperator.Equals,
                Value = "xyz"
            };

            _mockSubscriberContractRepository.Setup(d => d.GetAsync(_subscriberOneConfig.Id, _contractDto.Id)).ReturnsAsync(_contractDto);
            _mockEventSubscriptionAddressRepository.Setup(d => d.GetManyAsync(_eventSubscriptionConfig.Id)).ReturnsAsync(new[] { _addressesConfig });
            _mockParameterConditionRepository.Setup(d => d.GetManyAsync(_eventSubscriptionConfig.Id)).ReturnsAsync(new[] { _parameterConditionConfig });
        }