public void Round_robins_across_instances_in_pool() { var settings = new DefaultConfigurationValues().Apply(new SettingsHolder()); var creator = new InterceptedFactoryCreator(); var lifecycleManager = new MessagingFactoryLifeCycleManager(creator, settings); var poolSize = settings.Get <int>(WellKnownConfigurationKeys.Connectivity.MessagingFactories.NumberOfMessagingFactoriesPerNamespace); var first = lifecycleManager.Get(AzureServiceBusConnectionString.Value); var next = first; var reuseInPool = false; for (var i = 0; i < poolSize - 1; i++) { var n = lifecycleManager.Get(AzureServiceBusConnectionString.Value); reuseInPool &= next == n; next = n; } var second = lifecycleManager.Get(AzureServiceBusConnectionString.Value); Assert.IsFalse(reuseInPool); Assert.AreEqual(first, second); }
public void Replaces_factories_when_closed() { var settings = new DefaultConfigurationValues().Apply(new SettingsHolder()); settings.Set(WellKnownConfigurationKeys.Connectivity.MessagingFactories.NumberOfMessagingFactoriesPerNamespace, 1); // pool size of 1 simplifies the test var creator = new InterceptedFactoryCreator(); var lifecycleManager = new MessagingFactoryLifeCycleManager(creator, settings); var first = (InterceptedFactory)lifecycleManager.Get(AzureServiceBusConnectionString.Value); first.Close(); var second = (InterceptedFactory)lifecycleManager.Get(AzureServiceBusConnectionString.Value); Assert.AreEqual(2, creator.InvocationCount); Assert.AreNotEqual(first, second); }
public void Creates_a_pool_of_factories_for_namespace() { var settings = new DefaultConfigurationValues().Apply(new SettingsHolder()); var poolSize = settings.Get <int>(WellKnownConfigurationKeys.Connectivity.MessagingFactories.NumberOfMessagingFactoriesPerNamespace); var creator = new InterceptedFactoryCreator(); var lifecycleManager = new MessagingFactoryLifeCycleManager(creator, settings); lifecycleManager.Get(AzureServiceBusConnectionString.Value); Assert.AreEqual(poolSize, creator.InvocationCount); }