Beispiel #1
0
        private void AddChannel(out EventChannelRepository eventChannelRepository, out EventChannel channel, int timeout = 30)
        {
            //Arrange
            eventChannelRepository = new EventChannelRepository("ECommerce.Data.FileStore",
                                                                new ConnectionOptions
            {
                Provider         = "FileDb",
                ConnectionString = new FileInfo($"data\\data_{Guid.NewGuid()}.json").FullName
            },
                                                                _loggerFactory, new MyDiagnosticSource());
            var channelService = new EventChannelService
                                 (
                eventChannelRepository
                                 );

            channel = EventChannelRegistrationTests.AddChannel(channelService, timeout);

            channel.Should().NotBeNull();
        }
Beispiel #2
0
        public void ShouldRegiserAChannelAndSubscribe()
        {
            //Arrange
            var eventChannelRepository = new EventChannelRepository("ECommerce.Data.FileStore",
                                                                    new ConnectionOptions
            {
                Provider         = "FileDb",
                ConnectionString = new FileInfo($"data\\data_{Guid.NewGuid()}.json").FullName
            },
                                                                    _loggerFactory, new MyDiagnosticSource());

            var channelService = new EventChannelService
                                 (
                eventChannelRepository
                                 );

            var channel = EventChannelRegistrationTests.AddChannel(channelService);

            //Arrange Subscription service
            var subscriptionService = new EventSubscriptionService
                                      (
                new EventSubscriptionRepository(eventChannelRepository, "ECommerce.Data.FileStore",
                                                new ConnectionOptions
            {
                Provider         = "FileDb",
                ConnectionString = new FileInfo($"data\\data_{Guid.NewGuid()}.json").FullName
            },
                                                _loggerFactory, new MyDiagnosticSource())
                                      );

            var subscriptionResult = subscriptionService.SubscribeAsync(new EventSubscription
            {
                Channel = channel,
                Key     = Guid.NewGuid().ToString()
            }).Result;

            //Assert
            subscriptionResult.Should().NotBeNull();
            subscriptionResult.IsSuccessful.Should().BeTrue();
        }