Skip to content

Instantly share code, notes, and snippets.

@christopherbauer
Created June 29, 2015 18:08
Show Gist options
  • Save christopherbauer/7992511a879f4a695702 to your computer and use it in GitHub Desktop.
Save christopherbauer/7992511a879f4a695702 to your computer and use it in GitHub Desktop.
[TestFixture]
public class when_getting_the_a_connection
{
[Test]
public void then_should_return_a_new_instance_of_an_odbc_connection()
{
// Arrange
const string connectionString = "Server=Localhost;";
var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.ConnectionStrings.ConnectionStrings.Remove("AS400ConnectionString");
config.ConnectionStrings.ConnectionStrings.Add(new ConnectionStringSettings("AS400ConnectionString", connectionString));
config.Save(ConfigurationSaveMode.Modified, true);
ConfigurationManager.RefreshSection("connectionStrings");
var provider = new DbConnectionProvider();
// Act
var connection = provider.As400Connection;
// Assert
Assert.That(connection, Is.Not.Null.And.Matches<OdbcConnection>(c => c.ConnectionString == connectionString));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment