public void DatabaseFixtureSetUp() { var testdataDatabaseXsd01 = GetDataSchemaFile(); var testdataTestdataXml01 = GetDataFile(); var connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["IntegrationTests.Properties.Settings.TDDWithMVCConnectionString"].ConnectionString; _mySqlDatabase = new SqlDbUnitTest(connectionString); _mySqlDatabase.ReadXmlSchema(testdataDatabaseXsd01); _mySqlDatabase.ReadXml(testdataTestdataXml01); }
/// <summary> /// Loads the database with existing data. /// </summary> /// <param name="connectionString">The connection string.</param> /// <param name="schemaFilePathName">Name of the schema file path.</param> /// <param name="datasetFilePathName">Name of the dataset file path.</param> /// <param name="clientType">Type of the client.</param> /// <remarks>Loads all data from the datasetFilePathName .XML file into all tables contained in the schemaFilePathName .XSD file.</remarks> protected virtual void LoadDatabase(string connectionString, string schemaFilePathName, string datasetFilePathName, DatabaseClientType clientType) { ValidateConnectionString(connectionString); ValidateSupportFileExists(schemaFilePathName); ValidateSupportFileExists(datasetFilePathName); _database = GetDatabase(connectionString, clientType); _database.ReadXmlSchema(schemaFilePathName); _database.ReadXml(datasetFilePathName); _database.PerformDbOperation(NDbUnit.Core.DbOperationFlag.CleanInsertIdentity); }
/// <summary> /// Saves the existing database. /// </summary> /// <param name="connectionString">The connection string.</param> /// <param name="schemaFilePathName">Name of the schema file path.</param> /// <param name="datasetFilePathName">Name of the dataset file path.</param> /// <param name="clientType">Type of the client.</param> protected virtual void SaveDatabase(string connectionString, string schemaFilePathName, string datasetFilePathName, DatabaseClientType clientType) { ValidateConnectionString(connectionString); ValidateSupportFileExists(schemaFilePathName); ValidateSupportDirectoryExists(datasetFilePathName); _database = GetDatabase(connectionString, clientType); _database.ReadXmlSchema(schemaFilePathName); using (DataSet ds = _database.GetDataSetFromDb()) { ds.WriteXml(datasetFilePathName); } }