Ejemplo n.º 1
0
        public void Publish_TestEvent_NoExceptions()
        {
            // Arrange
            IDictionary <Guid, Tuple <bool, Exception> > testResponse = new Dictionary <Guid, Tuple <bool, Exception> >();

            Guid processId = Guid.NewGuid();

            testResponse.Add(processId, new Tuple <bool, Exception>(false, null));
            var @event = new TestEvent {
                Id = processId
            };

            var azureEventBusReceiver = new AzureEventBusReceiver <Guid>(new ConfigurationManager(), new MessageSerialiser <Guid>(), new GuidAuthenticationTokenHelper(), new NullCorrelationIdHelper(), new ConsoleLogger(new LoggerSettingsConfigurationSection(), new NullCorrelationIdHelper()), new AzureBusHelper <Guid>(new GuidAuthenticationTokenHelper(), new NullCorrelationIdHelper(), new ConsoleLogger(new LoggerSettingsConfigurationSection(), new NullCorrelationIdHelper()), new MessageSerialiser <Guid>(), new BusHelper(new ConfigurationManager(), new ThreadedContextItemCollectionFactory()), new BuiltInHashAlgorithmFactory(), new ConfigurationManager(), null), new BusHelper(new ConfigurationManager(), new ThreadedContextItemCollectionFactory()));
            var handler = new TestEventSuccessHandler(testResponse);

            azureEventBusReceiver.RegisterHandler <TestEvent>(handler.Handle, handler.GetType());
            azureEventBusReceiver.Start();

            var azureEventBusPublisher = new AzureEventBusPublisher <Guid>(new ConfigurationManager(), new MessageSerialiser <Guid>(), new GuidAuthenticationTokenHelper(), new NullCorrelationIdHelper(), new ConsoleLogger(new LoggerSettingsConfigurationSection(), new NullCorrelationIdHelper()), new AzureBusHelper <Guid>(new GuidAuthenticationTokenHelper(), new NullCorrelationIdHelper(), new ConsoleLogger(new LoggerSettingsConfigurationSection(), new NullCorrelationIdHelper()), new MessageSerialiser <Guid>(), new BusHelper(new ConfigurationManager(), new ThreadedContextItemCollectionFactory()), new BuiltInHashAlgorithmFactory(), new ConfigurationManager(), null), new BusHelper(new ConfigurationManager(), new ThreadedContextItemCollectionFactory()));

            // Act
            azureEventBusPublisher.Publish(@event);

            // Assert
            SpinWait.SpinUntil(() => testResponse[processId].Item1);
            Assert.IsNull(testResponse[processId].Item2);
        }
Ejemplo n.º 2
0
        public void Publish_TestEvent_NoExceptions()
        {
            // Arrange
            IDictionary <Guid, Tuple <bool, Exception> > testResponse = new Dictionary <Guid, Tuple <bool, Exception> >();

            Guid processId = Guid.NewGuid();

            testResponse.Add(processId, new Tuple <bool, Exception>(false, null));
            var @event = new TestEvent {
                Id = processId
            };
            IConfigurationManager configurationManager;

#if NET472
            configurationManager = new Configuration.ConfigurationManager();
#else
            IConfigurationRoot config = new ConfigurationBuilder()
                                        .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
                                        .AddEnvironmentVariables()
                                        .Build();

            configurationManager = new CloudConfigurationManager(config);
#endif

            var azureEventBusReceiver = new AzureEventBusReceiver <Guid>(configurationManager, new MessageSerialiser <Guid>(), new GuidAuthenticationTokenHelper(), new NullCorrelationIdHelper(), new ConsoleLogger(new LoggerSettingsConfigurationSection(), new NullCorrelationIdHelper()), new AzureBusHelper <Guid>(new GuidAuthenticationTokenHelper(), new NullCorrelationIdHelper(), new ConsoleLogger(new LoggerSettingsConfigurationSection(), new NullCorrelationIdHelper()), new MessageSerialiser <Guid>(), new BusHelper(configurationManager, new ContextItemCollectionFactory()), new BuiltInHashAlgorithmFactory(), configurationManager, null), new BusHelper(configurationManager, new ContextItemCollectionFactory()), new BuiltInHashAlgorithmFactory());
            var handler = new TestEventSuccessHandler(testResponse);
            azureEventBusReceiver.RegisterHandler <TestEvent>(handler.Handle, handler.GetType());
            azureEventBusReceiver.Start();

            var azureEventBusPublisher = new AzureEventBusPublisher <Guid>(configurationManager, new MessageSerialiser <Guid>(), new GuidAuthenticationTokenHelper(), new NullCorrelationIdHelper(), new ConsoleLogger(new LoggerSettingsConfigurationSection(), new NullCorrelationIdHelper()), new AzureBusHelper <Guid>(new GuidAuthenticationTokenHelper(), new NullCorrelationIdHelper(), new ConsoleLogger(new LoggerSettingsConfigurationSection(), new NullCorrelationIdHelper()), new MessageSerialiser <Guid>(), new BusHelper(configurationManager, new ContextItemCollectionFactory()), new BuiltInHashAlgorithmFactory(), configurationManager, null), new BusHelper(configurationManager, new ContextItemCollectionFactory()), new BuiltInHashAlgorithmFactory());

            // Act
            azureEventBusPublisher.Publish(@event);

            // Assert
            SpinWait.SpinUntil(() => testResponse[processId].Item1);
            Assert.IsNull(testResponse[processId].Item2);
        }