Exemplo n.º 1
0
        public void Can_insert_a_server_manager_creator()
        {
            lock (_lock)
            {
                try
                {
                    ServerManagerFactory.SetAlternateManagerCreationCallback(b => new StubServerManager());
                    var manager = ServerManagerFactory.Get(new ConnectionBuilder("Server=unit-test-1111"));

                    Assert.IsType <StubServerManager>(manager);
                }
                finally
                {
                    ServerManagerFactory.SetAlternateManagerCreationCallback(null);
                }
            }
        }
Exemplo n.º 2
0
        public void Manager_creator_can_be_optional()
        {
            lock (_lock)
            {
                try
                {
                    ServerManagerFactory.SetAlternateManagerCreationCallback(
                        b => b.Servers[0].Host == "unit-test-2222b" ? new StubServerManager() : null
                        );
                    var manager1 = ServerManagerFactory.Get(new ConnectionBuilder("Server=unit-test-2222a"));
                    var manager2 = ServerManagerFactory.Get(new ConnectionBuilder("Server=unit-test-2222b"));

                    Assert.IsType <SingleServerManager>(manager1);
                    Assert.IsType <StubServerManager>(manager2);
                }
                finally
                {
                    ServerManagerFactory.SetAlternateManagerCreationCallback(null);
                }
            }
        }