コード例 #1
0
        public async Task EventSubscriptionAddresses()
        {
            var addr1 = new EventSubscriptionAddressDto {
                Id = 1, EventSubscriptionId = 99, Address = "xyz"
            };
            var addr2 = new EventSubscriptionAddressDto {
                Id = 2, EventSubscriptionId = 99, Address = "abc"
            };
            var addr3 = new EventSubscriptionAddressDto {
                Id = 3, EventSubscriptionId = 100, Address = "qer"
            };

            await Fixture.ConfigRepo.EventSubscriptionAddresses.UpsertAsync(addr1);

            await Fixture.ConfigRepo.EventSubscriptionAddresses.UpsertAsync(addr2);

            await Fixture.ConfigRepo.EventSubscriptionAddresses.UpsertAsync(addr3);

            var sub1Addresses = await Fixture.ConfigRepo.EventSubscriptionAddresses.GetManyAsync(99);

            var sub2Addresses = await Fixture.ConfigRepo.EventSubscriptionAddresses.GetManyAsync(100);

            Assert.Equal(2, sub1Addresses.Length);
            Assert.Single(sub2Addresses);

            Assert.Equal(addr1.Address, sub1Addresses[0].Address);
        }
コード例 #2
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 });
        }
 public EventSubscriptionAddressDto Add(EventSubscriptionAddressDto dto)
 {
     EventSubscriptionAddresses.Add(dto);
     return(dto);
 }