Esempio n. 1
0
        public void Publish_TestCommand_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 command = new TestCommand {
                Id = processId
            };

            var azureCommandBusReceiver = new AzureCommandBusReceiver <Guid>(new ConfigurationManager(), new BusHelper(new ConfigurationManager()), new MessageSerialiser <Guid>(), new GuidSingleSignOnTokenValueHelper(), new NullCorrelationIdHelper(), new ConsoleLogger(new LoggerSettingsConfigurationSection(), new NullCorrelationIdHelper()));
            var handler = new TestCommandSuccessHandler(testResponse);

            azureCommandBusReceiver.RegisterHandler <TestCommand>(handler.Handle, handler.GetType());

            var azureCommandBusPublisher = new AzureCommandBusPublisher <Guid>(new ConfigurationManager(), new BusHelper(new ConfigurationManager()), new MessageSerialiser <Guid>(), new GuidSingleSignOnTokenValueHelper(), new NullCorrelationIdHelper(), new ConsoleLogger(new LoggerSettingsConfigurationSection(), new NullCorrelationIdHelper()), null);

            // Act
            azureCommandBusPublisher.Send(command);

            // Assert
            SpinWait.SpinUntil(() => testResponse[processId].Item1);
            Assert.IsNull(testResponse[processId].Item2);
        }
Esempio n. 2
0
        public void Publish_TestCommand_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 command = new TestCommand {
                Id = processId
            };

            var azureCommandBusReceiver = new AzureCommandBusReceiver <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 TestCommandSuccessHandler(testResponse);

            azureCommandBusReceiver.RegisterHandler <TestCommand>(handler.Handle, handler.GetType());
            azureCommandBusReceiver.Start();

            var azureCommandBusPublisher = new AzureCommandBusPublisher <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
            azureCommandBusPublisher.Publish(command);

            // Assert
            SpinWait.SpinUntil(() => testResponse[processId].Item1);
            Assert.IsNull(testResponse[processId].Item2);
        }
        public void Publish_TestCommand_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 command = new TestCommand {
                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 azureCommandBusReceiver = new AzureCommandBusReceiver <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 TestCommandSuccessHandler(testResponse);
            azureCommandBusReceiver.RegisterHandler <TestCommand>(handler.Handle, handler.GetType());
            azureCommandBusReceiver.Start();

            var azureCommandBusPublisher = new AzureCommandBusPublisher <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
            azureCommandBusPublisher.Publish(command);

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