public IConnectionstringArguments Map(DatabaseConnection databaseConnection) { return new AccessConnectionstringArguments { DatabaseType = DatabaseType.Access, DataSource = databaseConnection.DataSource, Password = databaseConnection.Password, Provider = databaseConnection.Provider, Username = databaseConnection.Username }; }
public IConnectionstringArguments Map(DatabaseConnection databaseConnection) { return new SqlServerConnectionstringArguments { DataSource = databaseConnection.DataSource, DatabaseName = databaseConnection.DatabaseName, DatabaseType = MapDatabaseType(databaseConnection.DatabaseType), Username = databaseConnection.Username, Password = databaseConnection.Password, Provider = databaseConnection.Provider }; }
public PartialViewResult GetTablesList(DatabaseConnection databaseConnection) { try { var connectionstringArgumentMapper = _connectionstringArgumentsMapperFactory.Make(databaseConnection.DatabaseType); var connectionstringArguments = connectionstringArgumentMapper.Map(databaseConnection); Connectionstring = _connectionstringBuilder.BuildConnectionString(connectionstringArguments); var tables = _schemaReader.GetTablesName(Connectionstring); return PartialView("TablesList", tables); } catch (Exception exception) { var message = exception.Message; return PartialView("Error", message); } }
public void Should_be_able_to_map_databaseconnection_to_connectionstringargument() { var databaseConnection = new DatabaseConnection { DataSource = "DataSource", DatabaseName = "DatabaseName", Password = "******", Username = "******", Provider = "Provider", DatabaseType = "SqlServer" }; var connectionstringArguments = _connectionstringArgumentsMapper.Map(databaseConnection); Assert.IsNotNull(connectionstringArguments); Assert.AreEqual("DataSource", connectionstringArguments.DataSource); Assert.AreEqual("DatabaseName", connectionstringArguments.DatabaseName); Assert.AreEqual("Provider", connectionstringArguments.Provider); Assert.AreEqual("Username", connectionstringArguments.Username); Assert.AreEqual("Password", connectionstringArguments.Password); Assert.AreEqual(DatabaseType.SqlServer, connectionstringArguments.DatabaseType); }