public void SetFixture(SetUpSqlData data) { _st = data; _options = new MySqlDbExportOptions(); _conn = new MySqlConnection(SetUpDatabaseTestsBase.GetConnectionString(_st.HostName, _st.Port, "test", "test", false, null)); _saveToFile = Environment.CurrentDirectory + @"\mydump.sql"; }
public void CanLoadAllOptions() { var testOptions = new MySqlDbExportOptions(); testOptions.no_data = true; testOptions.insert_ignore = true; testOptions.ignore_table = "nameoftable"; testOptions.routines = true; testOptions.lock_tables = true; testOptions.port = 3305; testOptions.allow_keywords = true; string fullPath; var isoStore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Assembly, null, null); using (IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream("Testfile.cnf", FileMode.OpenOrCreate, isoStore)) { using (StreamWriter writer = new StreamWriter(isoStream)) { writer.WriteLine("[mysqldump]"); writer.WriteLine("user=test;"); writer.WriteLine("password=test;"); } var fieldInfo = isoStream.GetType().GetField("m_FullPath", BindingFlags.Instance | BindingFlags.NonPublic); Assert.True(fieldInfo != null); fullPath = fieldInfo.GetValue(isoStream).ToString(); } var mysqldumpFacade = new MySqlDumpFacade(testOptions, _saveToFile, fullPath); var arguments = mysqldumpFacade.GetType().GetField("_arguments", BindingFlags.NonPublic | BindingFlags.Instance); if (arguments != null) { isoStore.DeleteFile("Testfile.cnf"); isoStore.Close(); string expected = @"--add-drop-database --add-drop-table --add-locks=false --all-databases=false --allow-keywords --comments --compact=false --complete-insert=false --create-options --databases --default-character-set=utf8 --delayed-insert=false --disable-keys --events=false --extended-insert --flush-logs=false --hex-blob=false --ignore-table=nameoftable --insert-ignore --lock-tables --no-data --no-create-info=false --max_allowed_packet=1G --order-by-primary=false --port=3305 --quote-names --replace=false --routines --single-transaction=false --set-gtid-purged=OFF """; var value = arguments.GetValue(mysqldumpFacade); Assert.True(value.ToString().Contains(expected)); } }