private void FindAllDatabases() { IList <DatabaseInfo> list = null; int processed = 0; var sw = new Stopwatch(); try { sw.Start(); var p = new DatabaseProcessor(_connection, _testMode); list = p.SearchDatabases(out processed); Console.WriteLine("Database list: "); foreach (var db in list) { Console.WriteLine($"\t{db.Database} ---> affected rows: {db.AffectedRows}"); } File.WriteAllLines("FoundedDbs", list.Select(l => $"{l.Database} ----> affected rows: {l.AffectedRows}")); } catch (Exception ex) { var color = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine($"Something go wrong when database try to find"); Console.WriteLine(ex); Console.ForegroundColor = color; } finally { sw.Stop(); Console.WriteLine($"End database list. Processed: {processed}; Founded: {list?.Count ?? 0}; Time: {sw.Elapsed}"); } }
protected override LoadContainer BuildTopology(TopologyExtractorFactoryContext topologyExtractorContext) { TopologyExtractorFactory loadBalancingLocalFactory = topologyExtractorContext.GetLoadBalancingLocalFactory(false); DirectoryServer localServer = base.ServiceContext.Directory.GetLocalServer(); TopologyExtractor extractor = loadBalancingLocalFactory.GetExtractor(localServer); LoadContainer loadContainer = extractor.ExtractTopology(); ExAssert.RetailAssert(loadContainer != null, "Extracted toplogy for server '{0}' should never be null.", new object[] { localServer }); DatabaseCollector databaseCollector = new DatabaseCollector(); loadContainer.Accept(databaseCollector); IOperationRetryManager operationRetryManager = LoadBalanceOperationRetryManager.Create(1, TimeSpan.Zero, base.ServiceContext.Logger); foreach (LoadContainer loadContainer2 in databaseCollector.Databases) { DirectoryDatabase directoryDatabase = loadContainer2.DirectoryObject as DirectoryDatabase; if (directoryDatabase != null) { DatabaseProcessor @object = new DatabaseProcessor(base.ServiceContext.Settings, base.ServiceContext.DrainControl, base.ServiceContext.Logger, directoryDatabase); operationRetryManager.TryRun(new Action(@object.ProcessDatabase)); } } return(loadContainer); }
private void ClearDatabase(string database, int surveyId = -1) { var sw = new Stopwatch(); Console.WriteLine($"Start Clear Database: {database}"); sw.Start(); var p = new DatabaseProcessor(_connection, _testMode); try { p.ClearDatabase(database, surveyId); } catch (Exception ex) { var color = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine($"Something go wrong with db: {database}"); Console.WriteLine(ex); Console.ForegroundColor = color; } sw.Stop(); Console.WriteLine($"End Clear Database {database}. Time: {sw.Elapsed}"); }
public void The_New_Tables_Are_In_The_ResultSet() { Database db1 = TestDatabaseLoader.TestDatabase(); Database db2 = TestDatabaseLoader.TestDatabase(); db2.AddTable(new Table("Table2")); db2.AddTable(new Table("aaaaaaa")); DatabaseMergeResult result = new DatabaseProcessor().MergeDatabases(db1, db2); Assert.That(result.ColumnOperations, Is.Empty); Assert.That(result.IndexOperations, Is.Empty); Assert.That(result.KeyOperations, Is.Empty); Assert.That(result.TableOperations, Has.Count(2)); var op = (TableAdditionOperation)result.TableOperations.ElementAt(0); Assert.That(op, Is.Not.Null); Assert.That(op.Object, Is.SameAs(db2.Tables[1])); Assert.That(op.Database, Is.SameAs(db1)); op = (TableAdditionOperation)result.TableOperations.ElementAt(1); Assert.That(op, Is.Not.Null); Assert.That(op.Object, Is.SameAs(db2.Tables[2])); Assert.That(op.Database, Is.SameAs(db1)); }
public void The_Removed_Column_And_The_Changed_Key_Are_In_The_ResultSet() { Database db1 = TestDatabaseLoader.TestDatabase(); Database db2 = TestDatabaseLoader.TestDatabase(); db2.Tables[0].RemoveKey(db2.Tables[0].Keys[0]); db2.Tables[0].RemoveIndex(db2.Tables[0].Indexes[0]); db2.Tables[0].RemoveColumn(db2.Tables[0].Columns[0]); DatabaseMergeResult result = new DatabaseProcessor().MergeDatabases(db1, db2); Assert.That(result.TableOperations, Is.Empty); Assert.That(result.IndexOperations, Has.Count(1), "There should be one Index operation"); var indexOp = result.IndexOperations.ElementAt(0); Assert.That(indexOp, Is.TypeOf(typeof(IndexRemovalOperation))); Assert.That(indexOp.Object, Is.SameAs(db1.Tables[0].Indexes[0]), "Removed index should be equal to PK_Table1 from db1"); Assert.That(result.KeyOperations, Has.Count(1), "There should be one Key operation"); var keyOp = result.KeyOperations.ElementAt(0); Assert.That(keyOp, Is.TypeOf(typeof(KeyRemovalOperation))); Assert.That(keyOp.Object, Is.SameAs(db1.Tables[0].Keys[0]), "Removed Key should be equal to PK_Table1 from db1"); Assert.That(result.ColumnOperations, Has.Count(1), "There should be one Column operation"); IMergeOperation <IColumn> columnOp = result.ColumnOperations.ElementAt(0); Assert.That(columnOp, Is.TypeOf(typeof(ColumnRemovalOperation))); Assert.That(columnOp.Object, Is.SameAs(db1.Tables[0].Columns[0]), "Removed column should be equal to Table1.Column1 from db1"); }
public void The_New_Tables_Are_In_The_ResultSet() { Database db1 = TestDatabaseLoader.TestDatabase(); Database db2 = TestDatabaseLoader.TestDatabase(); db2.AddTable(new Table("Table2")); db2.AddTable(new Table("aaaaaaa")); DatabaseMergeResult result = new DatabaseProcessor().MergeDatabases(db1, db2); Assert.That(result.ColumnOperations, Is.Empty); Assert.That(result.IndexOperations, Is.Empty); Assert.That(result.KeyOperations, Is.Empty); Assert.That(result.TableOperations, Has.Count(2)); var op = (TableAdditionOperation)result.TableOperations.ElementAt(0); Assert.That(op, Is.Not.Null); Assert.That(op.Object, Is.SameAs(db2.Tables[1])); Assert.That(op.Database, Is.SameAs(db1)); op = (TableAdditionOperation)result.TableOperations.ElementAt(1); Assert.That(op, Is.Not.Null); Assert.That(op.Object, Is.SameAs(db2.Tables[2])); Assert.That(op.Database, Is.SameAs(db1)); }
public IValidationResult Run(MappingSet set) { IValidationResult result = new ValidationResult(this); DatabaseProcessor proc = new DatabaseProcessor(); var mergeResults = proc.MergeDatabases(_realDatabase, set.Database); if (mergeResults.AnyChanges) { foreach (TableAdditionOperation tableOp in mergeResults.TableOperations.OfType <TableAdditionOperation>()) { // Additions show things that are in the generated database schema and not in the real one. result.Issues.Add(new ValidationIssue("Table exists in your NHibernate mapping files but not in your database", tableOp.Object, ValidationErrorLevel.Warning)); } foreach (ColumnAdditionOperation columnOp in mergeResults.ColumnOperations.OfType <ColumnAdditionOperation>()) { result.Issues.Add(new ValidationIssue("Column exists in your NHibernate mapping files but not in your database", columnOp.Object, ValidationErrorLevel.Warning)); } } return(result); }
/// <summary> /// The CreatePurchaseOrderDetails /// </summary> /// <param name="poId">The poId<see cref="int"/></param> private void CreatePurchaseOrderDetails(int poId) { foreach (var item in _purchaseOrderDto.productDetail) { object[,] objParams = new object[, ] { { "poId", poId }, { "prodId", item.Id }, { "prodAmount", item.Amount }, { "prodQty", item.Qty } }; using (SqlConnection conn = new SqlConnection(DatabaseProcessor.DatabaseConnectionString)) { var results = new DatabaseProcessor().Process("CreatePurchaseOrderDetail", objParams, conn); if (results != null) { results.Close(); } } } Invoke((MethodInvoker) delegate { Close(); }); }
/// <summary> /// The SavePurchaseOrder /// </summary> private void SavePurchaseOrder() { var poDescr = txtPODescr.Text; Task.Factory.StartNew(() => { object[,] objParams = new object[, ] { { "poDescr", poDescr }, { "poSupp", _suppId } }; using (SqlConnection conn = new SqlConnection(DatabaseProcessor.DatabaseConnectionString)) { var results = new DatabaseProcessor().ProcessWithOutput("CreatePurchaseOrder", objParams, conn, "poId"); if (results != null) { var dataReader = (SqlDataReader)results[0]; var poId = (int)results[1]; CreatePurchaseOrderDetails(poId); dataReader.Close(); MessageBox.Show("Purchase order created", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }); }
/// <summary> /// The RetrieveSupplierList /// </summary> private void RetrieveSupplierList() { Task.Factory.StartNew(() => { try { var suppliers = new DatabaseProcessor().RetrieveSuppliers("RetrieveSuppliers"); Invoke((MethodInvoker) delegate { cboSupps.DataSource = new BindingList <SupplierModel>(suppliers);; cboSupps.DisplayMember = "Name"; cboSupps.ValueMember = "Id"; PopulateProducts(); }); } catch (Exception ex) { Invoke((MethodInvoker) delegate { MessageBox.Show(ex.Message.ToString()); DisableControls(true); }); } }); }
public void The_New_Column_And_The_Changed_Key_Are_In_The_ResultSet() { Database db1 = TestDatabaseLoader.TestDatabase(); Database db2 = TestDatabaseLoader.TestDatabase(); db2.Tables[0].AddColumn(new Column("Column4") { InPrimaryKey = true }); db2.Tables[0].Keys[0].AddColumn("Column4"); db2.Tables[0].Indexes[0].AddColumn("Column4"); DatabaseMergeResult result = new DatabaseProcessor().MergeDatabases(db1, db2); Assert.That(result.TableOperations, Is.Empty); Assert.That(result.IndexOperations, Has.Count(1)); var indexOp = result.IndexOperations.ElementAt(0); Assert.That(indexOp, Is.TypeOf(typeof(IndexChangeOperation))); Assert.That(indexOp.Object, Is.SameAs(db1.Tables[0].Indexes[0]), "Changed index should be equal to PK_Table1 from db1"); Assert.That(result.KeyOperations, Has.Count(1)); var keyOp = result.KeyOperations.ElementAt(0); Assert.That(keyOp, Is.TypeOf(typeof(KeyChangeOperation))); Assert.That(keyOp.Object, Is.SameAs(db1.Tables[0].Keys[0]), "Changed Key should be equal to PK_Table1 from db1"); Assert.That(result.ColumnOperations, Has.Count(1)); IMergeOperation <IColumn> columnOp = result.ColumnOperations.ElementAt(0); Assert.That(columnOp, Is.TypeOf(typeof(ColumnAdditionOperation))); Assert.That(columnOp.Object, Is.SameAs(db2.Tables[0].Columns[3]), "Added column should be equal to Table1.Column4 from db2"); }
public void The_Removed_Columns_Are_In_The_ResultSet() { Database db1 = TestDatabaseLoader.TestDatabase(); db1.Tables[0].AddColumn(new Column("aaaaaa")); Database db2 = TestDatabaseLoader.TestDatabase(); db2.Tables[0].RemoveColumn(db1.Tables[0].Columns[2]); DatabaseMergeResult result = new DatabaseProcessor().MergeDatabases(db1, db2); Assert.That(result.TableOperations, Is.Empty); Assert.That(result.IndexOperations, Is.Empty); Assert.That(result.KeyOperations, Is.Empty); Assert.That(result.ColumnOperations, Is.Not.Empty); Assert.That(result.ColumnOperations, Has.Count(2)); IMergeOperation <IColumn> op = result.ColumnOperations.ElementAt(0); Assert.That(op.Object, Is.SameAs(db1.Tables[0].Columns[2])); Assert.That(op, Is.TypeOf(typeof(ColumnRemovalOperation))); op = result.ColumnOperations.ElementAt(1); Assert.That(op.Object, Is.SameAs(db1.Tables[0].Columns[3])); Assert.That(op, Is.TypeOf(typeof(ColumnRemovalOperation))); }
/// <summary> /// The SaveSupplier /// </summary> private void SaveSupplier() { object[,] objParams = new object[,] { { "suppName", txtSuppName.Text } }; try { using (SqlConnection conn = new SqlConnection(DatabaseProcessor.DatabaseConnectionString)) { var results = new DatabaseProcessor().Process("CreateSupplier", objParams, conn); if (results != null) { if (results.HasRows) { MessageBox.Show(results.GetString(0), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Supplier created", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); Invoke((MethodInvoker)delegate { Close(); }); } } results.Close(); } } catch (Exception ex) { throw new Exception(ex.Message.ToString()); } }
public void The_Removed_Keys_Are_In_The_ResultSet() { Database db1 = TestDatabaseLoader.TestDatabase(); // This key doesn't exist in the second db, so is effectively "removed" db1.Tables[0].AddKey(new Key("aaaaaa")); Database db2 = TestDatabaseLoader.TestDatabase(); db2.Tables[0].RemoveKey(db2.Tables[0].Keys[0]); DatabaseMergeResult result = new DatabaseProcessor().MergeDatabases(db1, db2); Assert.That(result.TableOperations, Is.Empty); Assert.That(result.IndexOperations, Is.Empty); Assert.That(result.ColumnOperations, Is.Empty); Assert.That(result.KeyOperations, Has.Count(2)); IMergeOperation <IKey> op = result.KeyOperations.ElementAt(0); Assert.That(op.Object, Is.SameAs(db1.Tables[0].Keys[0])); Assert.That(op, Is.TypeOf(typeof(KeyRemovalOperation))); op = result.KeyOperations.ElementAt(1); Assert.That(op.Object, Is.SameAs(db1.Tables[0].Keys[1])); Assert.That(op, Is.TypeOf(typeof(KeyRemovalOperation))); }
private void RefreshSchema() { // Note: this is only ok because this method only runs on the UI thread. // Two instances of it will not run at once, so this is not a race condition. // The moment it can run from another thread, this assumption is false and the // code is incorrect. if (RefreshingSchema) { return; } databaseLock.WaitOne(); RefreshingSchema = true; IDatabaseLoader loader = CreateDatabaseLoader(form); // Test connection first if (TestConnection(false) == false) { databaseLock.Set(); return; } Thread thread = new Thread( () => { try { IDatabase newDb = loader.LoadDatabase(loader.DatabaseObjectsToFetch, null); new DatabaseProcessor().CreateRelationships(newDb); if (Database == null || Database.IsEmpty) { Database = newDb; DatabaseConnector = loader.DatabaseConnector; NewDatabaseCreated.RaiseEvent(this); return; } var result = new DatabaseProcessor().MergeDatabases(Database, newDb); if (result.AnyChanges) { mainPanel.ShowDatabaseRefreshResults(result, Database, newDb); SchemaRefreshed.RaiseEvent(this); } else { form.SetDatabaseOperationResults(new DatabaseOperationResults("Schema Refresh", true, "No schema changes detected.")); } } finally { databaseLock.Set(); RefreshingSchema = false; } }); thread.Start(); }
private void RankingsWindow_Load(object sender, EventArgs e) { DatabaseProcessor DBprocessor = new DatabaseProcessor(); DataTable table = DBprocessor.LoadData(); UIOutput displayer = new UIOutput(); displayer.DisplayData(table, StuddyBuddyList, faculty); }
public void TestWipe() { var processor = new DatabaseProcessor <TestEntity>(new DummyDatabase()); processor.LoadIndex(); Assert.AreEqual(5, processor.Index.GetAll().Count); processor.Wipe(); Assert.AreEqual(0, processor.Index.GetAll().Count); }
public void The_ResultSet_Has_Nothing_in_It() { Database db1 = TestDatabaseLoader.TestDatabase(); Database db2 = TestDatabaseLoader.TestDatabase(); DatabaseMergeResult result = new DatabaseProcessor().MergeDatabases(db1, db2); Assert.That(result.TableOperations, Is.Empty); Assert.That(result.ColumnOperations, Is.Empty); Assert.That(result.IndexOperations, Is.Empty); Assert.That(result.KeyOperations, Is.Empty); }
static void PrintDelegateImplementation() { var database = new Database(); var databaseProcessor = new DatabaseProcessor(); Func <string, bool> sumHanlder = database.PersistToFile; sumHanlder += database.PersistToMSSQL; sumHanlder += database.PersistToMySQL; databaseProcessor.Process("test", sumHanlder); }
/// <summary> /// The UpdateProduct /// </summary> private void UpdateProduct() { var prodCode = string.Empty; var prodDescr = string.Empty; var prodAmount = 0D; var prodSuppId = 0; Invoke((MethodInvoker) delegate { prodCode = txtProdId.Text; prodDescr = txtProdDescr.Text; prodAmount = Convert.ToDouble(txtProdPrice.Text); prodSuppId = Convert.ToInt32(cboSupps.SelectedValue); }); object[,] objParams = new object[, ] { { "prodDescr", prodDescr }, { "prodAmount", prodAmount }, { "prodSuppId", prodSuppId }, { "prodCode", prodCode }, { "prodId", _product.Id } }; try { using (SqlConnection conn = new SqlConnection(DatabaseProcessor.DatabaseConnectionString)) { var results = new DatabaseProcessor().Process("UpdateProduct", objParams, conn); if (results != null) { if (results.HasRows) { MessageBox.Show(results.GetString(0), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Product updated", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); Invoke((MethodInvoker) delegate { Close(); }); } } results.Close(); } } catch (Exception ex) { throw new Exception(ex.Message.ToString()); } }
public void TestLoadRaw() { var processor = new DatabaseProcessor <TestEntity>(new DummyDatabase()); processor.LoadIndex(); var json = processor.LoadRaw("00000000-0000-0000-0000-000000000001"); Assert.AreEqual("00000000-0000-0000-0000-000000000001", json["Id"].ToString()); Assert.AreEqual(1, json["Age"].Value <int>()); Assert.AreEqual("FN1", json["Name"].ToString()); Assert.AreEqual("LN1", json["LastName"].ToString()); }
public void TestLoadIndex() { var processor = new DatabaseProcessor <TestEntity>(new DummyDatabase()); processor.LoadIndex(); foreach (var index in processor.Index.Raw) { Debug.LogWarning(index.ToString()); } Assert.IsNotNull(processor.Index); Assert.AreEqual(5, processor.Index.Raw.Count()); }
public void TestLoadData() { Debug.LogWarning(TestConstants.TestAssetPath); var processor = new DatabaseProcessor <TestEntity>(new DummyDatabase()); processor.LoadIndex(); var entity = processor.LoadData("00000000-0000-0000-0000-000000000001"); Assert.AreEqual("00000000-0000-0000-0000-000000000001", entity.Id.ToString()); Assert.AreEqual(1, entity.Age); Assert.AreEqual("FN1", entity.FirstName); Assert.AreEqual("LN1", entity.LastName); }
public void TestGetDataFiles() { var processor = new DatabaseProcessor <TestEntity>(new DummyDatabase()); var files = processor.GetDataFiles(); for (int i = 0; i < files.Length; i++) { Assert.AreEqual( Path.Combine(TestConstants.TestAssetPath, $"{TestDbFolder}/data/00000000-0000-0000-0000-00000000000{i}.data"), files[i].FullName ); } }
public void TestRebuildIndex() { var processor = new DatabaseProcessor <TestEntity>(new DummyDatabase()); var index = processor.Index; Assert.IsNull(index); processor.RebuildIndex(); index = processor.Index; Assert.IsNotNull(processor.Index); Assert.AreEqual(5, index.Raw.ToList().Count); processor.RebuildIndex(); Assert.AreNotEqual(index, processor.Index); Assert.AreEqual(5, index.Raw.ToList().Count); }
private void Submit_Click(object sender, EventArgs e) { if (FacultyComboBox.SelectedIndex >= 0) { if (StudiesComboBox.SelectedIndex >= 0) { AStuddyBuddy StuddyBuddy = new AStuddyBuddy(NicknameBox.Text.ToString(), LinkBox.Text.ToString(), FacultyComboBox.SelectedItem.ToString(), StudiesComboBox.SelectedItem.ToString()); RegexChecker regexObject = new RegexChecker(); DatabaseProcessor DBprocessor = new DatabaseProcessor(); bool nicknameValid = regexObject.CheckNickname(StuddyBuddy.Nickname); bool linkValid = regexObject.CheckLink(StuddyBuddy.Link); bool personExists = DBprocessor.FindExistingPerson(StuddyBuddy); if (nicknameValid && linkValid && !personExists) { DBprocessor.AddEntryToDatabase(StuddyBuddy); MessageBox.Show("Your nickname: " + StuddyBuddy.Nickname + Environment.NewLine + "Your Link: " + StuddyBuddy.Link + Environment.NewLine + "Chosen faculty: " + StuddyBuddy.Faculty + Environment.NewLine + "Chosen studies: " + StuddyBuddy.Studies + Environment.NewLine + "Your level: " + (Level)StuddyBuddy.Status); //LevelUp(StuddyBuddy); this.Close(); } else if (!nicknameValid) { MessageBox.Show("Nickname is not valid"); } else if (!linkValid) { MessageBox.Show("Link is not valid"); } else if (personExists) { MessageBox.Show("This person already exists"); } } } }
public void TestRemoveData() { var processor = new DatabaseProcessor <TestEntity>(new DummyDatabase()); processor.LoadIndex(); // Load all data first. List <TestEntity> data = new List <TestEntity>(); for (int i = 0; i < 5; i++) { data.Add(processor.LoadData($"00000000-0000-0000-0000-00000000000{i}")); var d = data[i]; Assert.AreEqual($"00000000-0000-0000-0000-00000000000{i}", d.Id.ToString()); Assert.AreEqual(i, d.Age); Assert.AreEqual($"FN{i}", d.FirstName); Assert.AreEqual($"LN{i}", d.LastName); } // Get deleting targets List <TestEntity> targets = new List <TestEntity>() { data[3], data[4] }; processor.RemoveData(targets); var index = processor.Index.GetAll(); Assert.AreEqual(3, index.Count); Assert.AreEqual(processor.GetDataFiles().Length, index.Count); for (int i = 0; i < 3; i++) { var d = processor.LoadData($"00000000-0000-0000-0000-00000000000{i}"); Assert.AreEqual($"00000000-0000-0000-0000-00000000000{i}", d.Id.ToString()); Assert.AreEqual(i, d.Age); Assert.AreEqual($"FN{i}", d.FirstName); Assert.AreEqual($"LN{i}", d.LastName); Assert.AreEqual(d.Id.ToString(), index[i]["Id"].ToString()); } }
private bool validateLogin() { warningText.SetActive(false); errorText.SetActive(false); myEmail = email.GetComponent <InputField>().text; myPassword = password.GetComponent <InputField>().text; if (myEmail == "" || myPassword == "") { warningText.SetActive(true); return(false); } else { DatabaseProcessor database = new DatabaseProcessor(); DataTable userData; string loginQuery = user.generatePersonQuery(myEmail, myPassword); database.Connect(); userData = database.GetData(loginQuery); if (userData.Rows.Count == 1) { user.PersonID1 = int.Parse(userData.Rows[0]["PersonID"].ToString()); user.Name1 = userData.Rows[0]["Name"].ToString(); user.Surname1 = userData.Rows[0]["Surname"].ToString(); user.OutlookMail1 = userData.Rows[0]["OutlookMail"].ToString(); user.Password1 = userData.Rows[0]["Password"].ToString(); user.Title1 = userData.Rows[0]["Title"].ToString(); user.Department1 = userData.Rows[0]["Department"].ToString(); user.Team1 = userData.Rows[0]["Team"].ToString(); user.Speciality1 = userData.Rows[0]["Speciality"].ToString(); user.PersonalInfo1 = userData.Rows[0]["PersonalInfo"].ToString(); user.ARFotoName1 = userData.Rows[0]["ARFotoName"].ToString(); return(true); } else { email.GetComponent <InputField>().text = ""; } myPassword = password.GetComponent <InputField>().text = ""; errorText.SetActive(true); return(false); } }
public void The_Removed_Table_Is_In_The_ResultSet() { Database db1 = TestDatabaseLoader.TestDatabase(); Database db2 = TestDatabaseLoader.TestDatabase(); db2.RemoveTable(db2.Tables[0]); DatabaseMergeResult result = new DatabaseProcessor().MergeDatabases(db1, db2); Assert.That(result.ColumnOperations, Is.Empty); Assert.That(result.IndexOperations, Is.Empty); Assert.That(result.KeyOperations, Is.Empty); Assert.That(result.TableOperations, Has.Count(1)); var op = (TableRemovalOperation)result.TableOperations.ElementAt(0); Assert.That(op, Is.Not.Null); Assert.That(op.Object, Is.SameAs(db1.Tables[0])); }
public void The_New_Key_Is_In_The_ResultSet() { Database db1 = TestDatabaseLoader.TestDatabase(); Database db2 = TestDatabaseLoader.TestDatabase(); db2.Tables[0].AddKey(new Key("PK_Table1_1")); DatabaseMergeResult result = new DatabaseProcessor().MergeDatabases(db1, db2); Assert.That(result.TableOperations, Is.Empty); Assert.That(result.IndexOperations, Is.Empty); Assert.That(result.ColumnOperations, Is.Empty); Assert.That(result.KeyOperations, Has.Count(1)); IMergeOperation <IKey> op = result.KeyOperations.ElementAt(0); Assert.That(op.Object, Is.SameAs(db2.Tables[0].Keys[1])); Assert.That(op, Is.TypeOf(typeof(KeyAdditionOperation))); }
public void The_Removed_Index_Is_In_The_ResultSet() { Database db1 = TestDatabaseLoader.TestDatabase(); Database db2 = TestDatabaseLoader.TestDatabase(); db2.Tables[0].RemoveIndex(db2.Tables[0].Indexes[0]); DatabaseMergeResult result = new DatabaseProcessor().MergeDatabases(db1, db2); Assert.That(result.TableOperations, Is.Empty); Assert.That(result.KeyOperations, Is.Empty); Assert.That(result.ColumnOperations, Is.Empty); Assert.That(result.IndexOperations, Has.Count(1)); IMergeOperation <IIndex> op = result.IndexOperations.ElementAt(0); Assert.That(op.Object, Is.SameAs(db1.Tables[0].Indexes[0])); Assert.That(op, Is.TypeOf(typeof(IndexRemovalOperation))); }
public void The_New_Key_Is_In_The_ResultSet() { Database db1 = TestDatabaseLoader.TestDatabase(); Database db2 = TestDatabaseLoader.TestDatabase(); db2.Tables[0].AddKey(new Key("PK_Table1_1")); db2.Tables[0].AddKey(new Key("OutOfOrderKey")); DatabaseMergeResult result = new DatabaseProcessor().MergeDatabases(db1, db2); Assert.That(result.TableOperations, Is.Empty); Assert.That(result.IndexOperations, Is.Empty); Assert.That(result.ColumnOperations, Is.Empty); Assert.That(result.KeyOperations, Has.Count(2)); IMergeOperation<IKey> op = result.KeyOperations.ElementAt(0); Assert.That(op.Object, Is.SameAs(db2.Tables[0].Keys[1])); Assert.That(op, Is.TypeOf(typeof(KeyAdditionOperation))); op = result.KeyOperations.ElementAt(1); Assert.That(op.Object, Is.SameAs(db2.Tables[0].Keys[2])); Assert.That(op, Is.TypeOf(typeof(KeyAdditionOperation))); }
public void The_Changed_Table_Is_In_The_ResultSet() { Database db1 = TestDatabaseLoader.TestDatabase(); db1.Tables[0].UID = new Guid(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); Database db2 = TestDatabaseLoader.TestDatabase(); db2.Tables[0].UID = new Guid(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); db2.Tables[0].Name = "SomethingElse"; DatabaseMergeResult result = new DatabaseProcessor().MergeDatabases(db1, db2); Assert.That(result.ColumnOperations, Is.Empty); Assert.That(result.IndexOperations, Is.Empty); Assert.That(result.KeyOperations, Is.Empty); Assert.That(result.TableOperations, Has.Count(1)); var op = (TableChangeOperation)result.TableOperations.ElementAt(0); Assert.That(op, Is.Not.Null); Assert.That(op.Object, Is.SameAs(db1.Tables[0])); }
public void The_Removed_Columns_Are_In_The_ResultSet() { Database db1 = TestDatabaseLoader.TestDatabase(); db1.Tables[0].AddColumn(new Column("aaaaaa")); Database db2 = TestDatabaseLoader.TestDatabase(); db2.Tables[0].RemoveColumn(db1.Tables[0].Columns[2]); DatabaseMergeResult result = new DatabaseProcessor().MergeDatabases(db1, db2); Assert.That(result.TableOperations, Is.Empty); Assert.That(result.IndexOperations, Is.Empty); Assert.That(result.KeyOperations, Is.Empty); Assert.That(result.ColumnOperations, Is.Not.Empty); Assert.That(result.ColumnOperations, Has.Count(2)); IMergeOperation<IColumn> op = result.ColumnOperations.ElementAt(0); Assert.That(op.Object, Is.SameAs(db1.Tables[0].Columns[2])); Assert.That(op, Is.TypeOf(typeof(ColumnRemovalOperation))); op = result.ColumnOperations.ElementAt(1); Assert.That(op.Object, Is.SameAs(db1.Tables[0].Columns[3])); Assert.That(op, Is.TypeOf(typeof(ColumnRemovalOperation))); }
public void The_Removed_Column_And_The_Changed_Key_Are_In_The_ResultSet() { Database db1 = TestDatabaseLoader.TestDatabase(); Database db2 = TestDatabaseLoader.TestDatabase(); db2.Tables[0].RemoveKey(db2.Tables[0].Keys[0]); db2.Tables[0].RemoveIndex(db2.Tables[0].Indexes[0]); db2.Tables[0].RemoveColumn(db2.Tables[0].Columns[0]); DatabaseMergeResult result = new DatabaseProcessor().MergeDatabases(db1, db2); Assert.That(result.TableOperations, Is.Empty); Assert.That(result.IndexOperations, Has.Count(1), "There should be one Index operation"); var indexOp = result.IndexOperations.ElementAt(0); Assert.That(indexOp, Is.TypeOf(typeof(IndexRemovalOperation))); Assert.That(indexOp.Object, Is.SameAs(db1.Tables[0].Indexes[0]), "Removed index should be equal to PK_Table1 from db1"); Assert.That(result.KeyOperations, Has.Count(1), "There should be one Key operation"); var keyOp = result.KeyOperations.ElementAt(0); Assert.That(keyOp, Is.TypeOf(typeof(KeyRemovalOperation))); Assert.That(keyOp.Object, Is.SameAs(db1.Tables[0].Keys[0]), "Removed Key should be equal to PK_Table1 from db1"); Assert.That(result.ColumnOperations, Has.Count(1), "There should be one Column operation"); IMergeOperation<IColumn> columnOp = result.ColumnOperations.ElementAt(0); Assert.That(columnOp, Is.TypeOf(typeof(ColumnRemovalOperation))); Assert.That(columnOp.Object, Is.SameAs(db1.Tables[0].Columns[0]), "Removed column should be equal to Table1.Column1 from db1"); }
public void The_New_Column_And_The_Changed_Key_Are_In_The_ResultSet() { Database db1 = TestDatabaseLoader.TestDatabase(); Database db2 = TestDatabaseLoader.TestDatabase(); db2.Tables[0].AddColumn(new Column("Column4") { InPrimaryKey = true}); db2.Tables[0].Keys[0].AddColumn("Column4"); db2.Tables[0].Indexes[0].AddColumn("Column4"); DatabaseMergeResult result = new DatabaseProcessor().MergeDatabases(db1, db2); Assert.That(result.TableOperations, Is.Empty); Assert.That(result.IndexOperations, Has.Count(1)); var indexOp = result.IndexOperations.ElementAt(0); Assert.That(indexOp, Is.TypeOf(typeof(IndexChangeOperation))); Assert.That(indexOp.Object, Is.SameAs(db1.Tables[0].Indexes[0]), "Changed index should be equal to PK_Table1 from db1"); Assert.That(result.KeyOperations, Has.Count(1)); var keyOp = result.KeyOperations.ElementAt(0); Assert.That(keyOp, Is.TypeOf(typeof(KeyChangeOperation))); Assert.That(keyOp.Object, Is.SameAs(db1.Tables[0].Keys[0]), "Changed Key should be equal to PK_Table1 from db1"); Assert.That(result.ColumnOperations, Has.Count(1)); IMergeOperation<IColumn> columnOp = result.ColumnOperations.ElementAt(0); Assert.That(columnOp, Is.TypeOf(typeof(ColumnAdditionOperation))); Assert.That(columnOp.Object, Is.SameAs(db2.Tables[0].Columns[3]), "Added column should be equal to Table1.Column4 from db2"); }
public void The_Removed_Key_Is_In_The_ResultSet() { Database db1 = TestDatabaseLoader.TestDatabase(); Database db2 = TestDatabaseLoader.TestDatabase(); db2.Tables[0].RemoveKey(db2.Tables[0].Keys[0]); DatabaseMergeResult result = new DatabaseProcessor().MergeDatabases(db1, db2); Assert.That(result.TableOperations, Is.Empty); Assert.That(result.IndexOperations, Is.Empty); Assert.That(result.ColumnOperations, Is.Empty); Assert.That(result.KeyOperations, Has.Count(1)); IMergeOperation<IKey> op = result.KeyOperations.ElementAt(0); Assert.That(op.Object, Is.SameAs(db1.Tables[0].Keys[0])); Assert.That(op, Is.TypeOf(typeof(KeyRemovalOperation))); }
public void The_Removed_Keys_Are_In_The_ResultSet() { Database db1 = TestDatabaseLoader.TestDatabase(); // This key doesn't exist in the second db, so is effectively "removed" db1.Tables[0].AddKey(new Key("aaaaaa")); Database db2 = TestDatabaseLoader.TestDatabase(); db2.Tables[0].RemoveKey(db2.Tables[0].Keys[0]); DatabaseMergeResult result = new DatabaseProcessor().MergeDatabases(db1, db2); Assert.That(result.TableOperations, Is.Empty); Assert.That(result.IndexOperations, Is.Empty); Assert.That(result.ColumnOperations, Is.Empty); Assert.That(result.KeyOperations, Has.Count(2)); IMergeOperation<IKey> op = result.KeyOperations.ElementAt(0); Assert.That(op.Object, Is.SameAs(db1.Tables[0].Keys[0])); Assert.That(op, Is.TypeOf(typeof(KeyRemovalOperation))); op = result.KeyOperations.ElementAt(1); Assert.That(op.Object, Is.SameAs(db1.Tables[0].Keys[1])); Assert.That(op, Is.TypeOf(typeof(KeyRemovalOperation))); }
public void The_New_Index_Is_In_The_ResultSet() { Database db1 = TestDatabaseLoader.TestDatabase(); Database db2 = TestDatabaseLoader.TestDatabase(); db2.Tables[0].AddIndex(new Index("UQ_Table1_1")); DatabaseMergeResult result = new DatabaseProcessor().MergeDatabases(db1, db2); Assert.That(result.TableOperations, Is.Empty); Assert.That(result.KeyOperations, Is.Empty); Assert.That(result.ColumnOperations, Is.Empty); Assert.That(result.IndexOperations, Has.Count(1)); IMergeOperation<IIndex> op = result.IndexOperations.ElementAt(0); Assert.That(op.Object, Is.SameAs(db2.Tables[0].Indexes[1])); Assert.That(op, Is.TypeOf(typeof(IndexAdditionOperation))); }
public void The_Changed_Index_Is_In_The_ResultSet() { Database db1 = TestDatabaseLoader.TestDatabase(); db1.Tables[0].Indexes[0].UID = new Guid(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); Database db2 = TestDatabaseLoader.TestDatabase(); db2.Tables[0].Indexes[0].IsUnique = false; db2.Tables[0].Indexes[0].UID = new Guid(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); DatabaseMergeResult result = new DatabaseProcessor().MergeDatabases(db1, db2); Assert.That(result.TableOperations, Is.Empty); Assert.That(result.KeyOperations, Is.Empty); Assert.That(result.ColumnOperations, Is.Empty); Assert.That(result.IndexOperations, Has.Count(1)); IMergeOperation<IIndex> op = result.IndexOperations.ElementAt(0); Assert.That(op.Object, Is.SameAs(db1.Tables[0].Indexes[0])); Assert.That(op, Is.TypeOf(typeof(IndexChangeOperation))); }
public void The_Removed_Table_Is_In_The_ResultSet() { Database db1 = TestDatabaseLoader.TestDatabase(); Database db2 = TestDatabaseLoader.TestDatabase(); db2.RemoveTable(db2.Tables[0]); DatabaseMergeResult result = new DatabaseProcessor().MergeDatabases(db1, db2); Assert.That(result.ColumnOperations, Is.Empty); Assert.That(result.IndexOperations, Is.Empty); Assert.That(result.KeyOperations, Is.Empty); Assert.That(result.TableOperations, Has.Count(1)); var op = (TableRemovalOperation)result.TableOperations.ElementAt(0); Assert.That(op, Is.Not.Null); Assert.That(op.Object, Is.SameAs(db1.Tables[0])); }