public void FactoryReadsFromConfiguration() { // --- Arrange var registry = new DefaultResourceConnectionProviderRegistry(); registry.RegisterResourceConnectionProvider(typeof(MyConnection1)); registry.RegisterResourceConnectionProvider(typeof(MyConnection2)); ResourceConnectionProviderRegistry.Configure(registry); var providers = new ResourceConnectionProviderCollection { new MyConnection1("name1", 12345), new MyConnection1("name2", 54321), new MyConnection2("name3", "345"), new MyConnection2("name4", "678") }; var settings = new ResourceConnectionFactorySettings(providers); var element = settings.WriteToXml("ResourceConnections"); settings = new ResourceConnectionFactorySettings(element); var factory = new DefaultResourceConnectionFactory(settings); // --- Act var resource1 = factory.CreateResourceConnection <int>("name1"); var resource2 = factory.CreateResourceConnection <int>("name2"); var resource3 = factory.CreateResourceConnection <int>("name3"); var resource4 = factory.CreateResourceConnection <int>("name4"); // --- Assert resource1.ShouldEqual(12345); resource2.ShouldEqual(54321); resource3.ShouldEqual(345); resource4.ShouldEqual(678); }
public void TestInit() { AppConfigurationManager.Reset(); TypeResolver.Reset(); ResourceConnectionProviderRegistry.Reset(); ResourceConnectionFactory.Reset(); var settings = new TaskExecutionContextSettings("queue"); s_Context = new DefaultTaskExecutionContext(settings); s_PeekPolicy = new TestPeekPolicy(TimeSpan.FromMilliseconds(10)); }
public void ParseFailsWithUnknownProvider() { // --- Assert const string CONFIG = @"<ResourceConnections> <MyProvider name='queueDB' value='Data Source=.\sqlexpress;Integrated Security=True;Initial Catalog=Seemplest.Test;'/> </ResourceConnections>"; ResourceConnectionProviderRegistry.Reset(); // --- Act // ReSharper disable ObjectCreationAsStatement new ResourceConnectionFactorySettings(XElement.Parse(CONFIG)); // ReSharper restore ObjectCreationAsStatement }
public void ParseFailsWithProviderInitializationIssue() { // --- Assert const string CONFIG = @"<ResourceConnections> <MyProvider name='aaa' value='123' /> </ResourceConnections>"; ResourceConnectionProviderRegistry.Reset(); ResourceConnectionProviderRegistry.Current.RegisterResourceConnectionProvider(typeof(MyProvider)); // --- Act // ReSharper disable ObjectCreationAsStatement new ResourceConnectionFactorySettings(XElement.Parse(CONFIG)); // ReSharper restore ObjectCreationAsStatement }
public void OnConfigurationChangedWorksAsExpected() { // --- Arrange var onChangedCalled = false; var registry = new DefaultResourceConnectionProviderRegistry(); registry.RegisterResourceConnectionProvider(typeof(MyConnection1)); // --- Act ResourceConnectionProviderRegistry.ConfigurationChanged += (sender, args) => { onChangedCalled = true; }; ResourceConnectionProviderRegistry.Configure(registry); // --- Assert onChangedCalled.ShouldBeTrue(); }
public void Initilaize() { ResourceConnectionProviderRegistry.Reset(); ResourceConnectionFactory.Reset(); }