public void CreateConnectionUsesRegisteredProvider()
        {
            const string bankId1 = "TestBank1";
            const string bankId2 = "TestBank2";

            var testConnection1 = Substitute.For <IBankConnection>();
            var testConnection2 = Substitute.For <IBankConnection>();

            var testProvider1 = Substitute.For <IBankConnectionProvider>();

            testProvider1.BankId.Returns(bankId1);
            testProvider1.CreateConnection().Returns(testConnection1);

            var testProvider2 = Substitute.For <IBankConnectionProvider>();

            testProvider2.BankId.Returns(bankId2);
            testProvider2.CreateConnection().Returns(testConnection2);

            var connectionManager = new BankConnectionManager();

            connectionManager.RegisterConnectionProvider(testProvider1);
            connectionManager.RegisterConnectionProvider(testProvider2);

            var newConnection = connectionManager.CreateConnection(bankId1);

            Assert.That(newConnection, Is.EqualTo(testConnection1));
            Assert.That(newConnection, Is.Not.EqualTo(testConnection2));
        }
        public void CreateConnectionFailsWithNoRegisteredProvider()
        {
            const string bankId1 = "TestBank1";
            const string bankId2 = "TestBank2";

            var testConnection = Substitute.For <IBankConnection>();

            var testProvider1 = Substitute.For <IBankConnectionProvider>();

            testProvider1.BankId.Returns(bankId1);
            testProvider1.CreateConnection().Returns(testConnection);

            var connectionManager = new BankConnectionManager();

            connectionManager.RegisterConnectionProvider(testProvider1);

            Assert.Throws <InvalidOperationException>(
                () => connectionManager.CreateConnection(bankId2)
                );
        }