/// <summary> /// Initializes a new instance of the <see cref="PrototypeWithDatabaseNameTokenReplacementConnectionStringProvider"/> class using /// the specified "prototype" named connection string from the application configuration file and the supplied database name replacement token provider. /// </summary> /// <param name="prototypeConnectionStringName">The named connection string to use as the basis for building the connection string.</param> /// <param name="databaseNameReplacementTokenProvider">The provider that builds the database name replacement token for use in the resulting connection string.</param> /// <param name="configConnectionStringsProvider"></param> /// <param name="dbConnectionStringBuilderAdapterFactory"></param> public PrototypeWithDatabaseNameTokenReplacementConnectionStringProvider( string prototypeConnectionStringName, IDatabaseNameReplacementTokenProvider databaseNameReplacementTokenProvider, IConfigConnectionStringsProvider configConnectionStringsProvider, IDbConnectionStringBuilderAdapterFactory dbConnectionStringBuilderAdapterFactory) { _prototypeConnectionStringName = prototypeConnectionStringName; _databaseNameReplacementTokenProvider = databaseNameReplacementTokenProvider; _configConnectionStringsProvider = configConnectionStringsProvider; _dbConnectionStringBuilderAdapterFactory = dbConnectionStringBuilderAdapterFactory; }
protected override void Arrange() { // Set up mocked dependencies and supplied values _databaseReplacementTokenProvider = A.Fake <IDatabaseReplacementTokenProvider>(); A.CallTo(() => _databaseReplacementTokenProvider.GetDatabaseNameReplacementToken()) .Returns("Ods"); _configConnectionStringsProvider = A.Fake <IConfigConnectionStringsProvider>(); A.CallTo(() => _configConnectionStringsProvider.Count) .Returns(1); A.CallTo(() => _configConnectionStringsProvider.GetConnectionString("SomeConnectionStringName")) .Returns("Server=SomeServer; Database=EdFi_{0}; UID=SomeUser; Password=SomePassword"); _dbConnectionStringBuilderAdapterFactory = A.Fake <IDbConnectionStringBuilderAdapterFactory>(); A.CallTo(() => _dbConnectionStringBuilderAdapterFactory.Get()).Returns(new SqlConnectionStringBuilderAdapter()); }
protected override void Arrange() { _databaseReplacementTokenProvider = A.Fake <IDatabaseReplacementTokenProvider>(); A.CallTo(() => _databaseReplacementTokenProvider.GetServerNameReplacementToken()).Returns("OneDatabase"); _configConnectionStringsProvider = A.Fake <IConfigConnectionStringsProvider>(); A.CallTo(() => _configConnectionStringsProvider.Count).Returns(1); A.CallTo(() => _configConnectionStringsProvider.GetConnectionString(A <string> .Ignored)) .Returns("Server=SomeServer; Database=SomeDatabase; UID=SomeUser; Password=SomePassword") .Once(); A.CallTo(() => _configConnectionStringsProvider.GetConnectionString(A <string> .Ignored)) .Returns("Server=prefix_{0}_suffix; Database=SomeDatabase; UID=SomeUser; Password=SomePassword") .Once(); _dbConnectionStringBuilderAdapterFactory = A.Fake <IDbConnectionStringBuilderAdapterFactory>(); A.CallTo(() => _dbConnectionStringBuilderAdapterFactory.Get()).Returns(new SqlConnectionStringBuilderAdapter()); }
public InstanceAdminDatabaseNameTokenReplacementConnectionStringProvider(IConfigConnectionStringsProvider configConnectionStringsProvider, IDbConnectionStringBuilderAdapterFactory connectionStringBuilderFactory, IAdminDatabaseNameReplacementTokenProvider adminDatabaseNameReplacementTokenProvider) { _configConnectionStringsProvider = configConnectionStringsProvider; _connectionStringBuilderFactory = connectionStringBuilderFactory; _adminDatabaseNameReplacementTokenProvider = adminDatabaseNameReplacementTokenProvider; }
public DatabaseNameBuilder(IConfigConnectionStringsProvider connectionStringsProvider, IDbConnectionStringBuilderAdapterFactory connectionStringBuilderFactory) { _databaseNameTemplate = new Lazy <string>( () => { if (!connectionStringsProvider.ConnectionStringProviderByName.ContainsKey("EdFi_Ods")) { return(string.Empty); } var connectionStringBuilder = connectionStringBuilderFactory.Get(); connectionStringBuilder.ConnectionString = connectionStringsProvider.GetConnectionString("EdFi_Ods"); return(connectionStringBuilder.DatabaseName); }); }
public InstanceSecurityDatabaseNameTokenReplacementConnectionStringProvider(IConfigConnectionStringsProvider configConnectionStringsProvider, IDbConnectionStringBuilderAdapterFactory connectionStringBuilderFactory, ISecurityDatabaseNameReplacementTokenProvider securityDatabaseNameReplacementTokenProvider) { _configConnectionStringsProvider = configConnectionStringsProvider; _connectionStringBuilderFactory = connectionStringBuilderFactory; _securityDatabaseNameReplacementTokenProvider = securityDatabaseNameReplacementTokenProvider; }