public void CreateCodeEmployeeTerritoriesAfterUnmap() { TableNode tn; PrepareEmployeeTerritories(out tn); DatabaseNode dbn = (DatabaseNode)tn.Parent; IntermediateTableNode itn = (IntermediateTableNode)FindNode(dbn.Nodes, "EmployeeTerritories", typeof(IntermediateTableNode)); itn.UnmapIntermediateTable(null, EventArgs.Empty); ApplicationController.Instance.GenerateAssembly(); // There shouldn't be relations in the code }
public void TestIntermediateTable() { TableNode tn; PrepareEmployeeTerritories(out tn); DatabaseNode dbn = (DatabaseNode)tn.Parent; IntermediateTableNode itn = (IntermediateTableNode)FindNode(dbn.Nodes, "EmployeeTerritories", typeof(IntermediateTableNode)); Assertion.AssertNotNull("IntermediateTableNode not found", itn); Assertion.AssertEquals("Wrong original table", tn, itn.OriginalTableNode); Assertion.AssertEquals("Wrong image", itn.SelectedImageIndex, 13); tn = (TableNode)FindNode(dbn.Nodes, "Employees"); RelationNode rn = (RelationNode)FindNode(tn.Nodes, "EmployeeID", typeof(RelationNode)); Assertion.AssertNotNull("Relation node should exist #1", rn); tn = (TableNode)FindNode(dbn.Nodes, "Territories"); rn = (RelationNode)FindNode(tn.Nodes, "TerritoryID", typeof(RelationNode)); Assertion.AssertNotNull("Relation node should exist #2", rn); // Now unmap and test itn.UnmapIntermediateTable(null, EventArgs.Empty); itn = (IntermediateTableNode)FindNode(dbn.Nodes, "EmployeeTerritories", typeof(IntermediateTableNode)); Assertion.AssertNull("itn should be null", itn); tn = (TableNode)FindNode(dbn.Nodes, "EmployeeTerritories", typeof(TableNode)); Assertion.AssertNotNull("Table node should be back", tn); tn = (TableNode)FindNode(dbn.Nodes, "Employees"); rn = (RelationNode)FindNode(tn.Nodes, "EmployeeID", typeof(RelationNode)); Assertion.AssertNull("Relation node shouldn't be there", rn); tn = (TableNode)FindNode(dbn.Nodes, "Territories"); rn = (RelationNode)FindNode(tn.Nodes, "TerritoryID", typeof(RelationNode)); Assertion.AssertNull("Relation node shouldn't be there #2", rn); }