public void MergeNewConnStringClassChanged() { string file1 = "File1.Xml"; string file2 = "File2.Xml"; NDOMapping map1 = NDOMapping.Create(file1); map1.AddStandardClass(classMitarbeiter, assName, null); ((Connection)map1.Connections[0]).Name = "Alter ConnectionString"; map1.Save(); NDOMapping map2 = NDOMapping.Create(file2); map2.AddStandardClass(classMitarbeiter, assName, null); ((Connection)map2.Connections[0]).Name = "Neuer ConnectionString"; ((Class)map2.Classes[0]).AssemblyName = "New Assembly-Name"; map2.Save(); map1 = new NDOMapping(file1); map2 = new NDOMapping(file2); map1.MergeMapping(map2); Assert.AreEqual(2, map1.Connections.Count, "Falsche Anzahl Connections"); Assert.AreEqual(1, map1.Classes.Count, "Falsche Anzahl Klassen"); Class c = map1.FindClass(classMitarbeiter); Assert.NotNull(c, "Mitarbeiter nicht gefunden"); Assert.AreEqual("C1", c.ConnectionId, "Connection falsch"); File.Delete(file1); File.Delete(file2); }
public void MergeEqualNewConnName() { string file1 = "File1.Xml"; string file2 = "File2.Xml"; NDOMapping map1 = NDOMapping.Create(file1); map1.AddStandardClass(classMitarbeiter, assName, null); map1.Save(); NDOMapping map2 = NDOMapping.Create(file2); map2.AddStandardClass(classMitarbeiter, assName, null); ((Connection)map2.Connections[0]).ID = "C1"; map2.Save(); map1 = new NDOMapping(file1); map2 = new NDOMapping(file2); map1.MergeMapping(map2); Assert.AreEqual(1, map1.Classes.Count, "Falsche Anzahl Klassen"); Assert.AreEqual(1, map1.Connections.Count, "Falsche Anzahl Connections"); File.Delete(file1); File.Delete(file2); }
public void MergeNewConnStringFromDummy2() { string file1 = "File1.Xml"; string file2 = "File2.Xml"; NDOMapping map1 = NDOMapping.Create(file1); map1.AddStandardClass(classMitarbeiter, assName, null); map1.Save(); NDOMapping map2 = NDOMapping.Create(file2); map2.AddStandardClass(classMitarbeiter, assName, null); map2.Save(); map1 = new NDOMapping(file1); map2 = new NDOMapping(file2); Assert.AreEqual(Connection.DummyConnectionString, ((Connection)map1.Connections[0]).Name, "Must be dummy connection"); Assert.AreEqual(Connection.DummyConnectionString, ((Connection)map2.Connections[0]).Name, "Must be dummy connection"); ((Connection)map1.Connections[0]).Name = "Some new string"; map1.MergeMapping(map2); Assert.AreEqual(1, map1.Connections.Count, "Falsche Anzahl Connections"); Class c = map1.FindClass(classMitarbeiter); Assert.NotNull(c, "Mitarbeiter nicht gefunden"); Assert.AreEqual("C0", c.ConnectionId, "Connection falsch"); File.Delete(file1); File.Delete(file2); }
public void AnlegenNNRelation() { string testFile = "Test.Xml"; NDOMapping mapping = NDOMapping.Create(testFile); Class c = mapping.AddStandardClass(classMitarbeiter, assName, null); c.AddStandardRelation("dieReisen", "Reisekosten.Reise", false, "", false, false); c = mapping.AddStandardClass("Reisekosten.Reise", assName, null); c.AddStandardRelation("dieMitarbeiter", classMitarbeiter, false, "", false, false); mapping.Save(); mapping = new NDOMapping(testFile); Assert.AreEqual(1, mapping.Connections.Count, "Keine Connection"); Assert.AreEqual(2, mapping.Classes.Count, "Keine Klasse"); c = (Class)mapping.FindClass(classMitarbeiter); Assert.AreEqual("Mitarbeiter", c.TableName, "TableName falsch"); Assert.NotNull(c.Oid, "Keine Oid"); Assert.AreEqual(1, c.Relations.Count, "Keine Relation"); Relation r = c.FindRelation("dieReisen"); Assert.NotNull(r, "Relation dieReisen nicht gefunden"); Assert.AreEqual("IDMitarbeiter", ((ForeignKeyColumn)r.ForeignKeyColumns[0]).Name, "ForeignKeyColumnName falsch"); Assert.AreEqual("n:n", r.GetRelationType(), "Relationstyp falsch"); Assert.AreEqual("IDReise", ((ForeignKeyColumn)r.MappingTable.ChildForeignKeyColumns[0]).Name, "ChildForeignKeyColumnName von MappingTable falsch"); Assert.AreEqual("relMitarbeiterReise", r.MappingTable.TableName, "TableName von MappingTable falsch"); c = mapping.FindClass("Reisekosten.Reise"); r = c.FindRelation("dieMitarbeiter"); Assert.NotNull(r, "Relation dieMitarbeiter nicht gefunden"); Assert.AreEqual("relMitarbeiterReise", r.MappingTable.TableName, "TableName von MappingTable falsch"); Assert.AreEqual("n:n", r.GetRelationType(), "Relationstyp falsch"); Assert.AreEqual("IDReise", ((ForeignKeyColumn)r.ForeignKeyColumns[0]).Name, "ForeignKeyColumnName falsch"); Assert.AreEqual("IDMitarbeiter", ((ForeignKeyColumn)r.MappingTable.ChildForeignKeyColumns[0]).Name, "ChildForeignKeyColumnName von MappingTable falsch"); }
public void AssembyWideColumnAttributeOverwritesDefaultValues() { NDOMapping mapping = NDOMapping.Create(null); var cls = mapping.AddStandardClass("TestClass", "TestAssembly", null); Assert.AreEqual(1, cls.Oid.OidColumns.First().AutoIncrementStart); var attr = new OidColumnAttribute() { Name = "newColumnName", AutoIncrementStart = 2, IsAssemblyWideDefinition = true }; cls.Oid.RemapOidColumns(new[] { attr }); Assert.AreEqual(2, cls.Oid.OidColumns.First().AutoIncrementStart); }
public void OidColumnShouldntBeRemappedWithAssembyWideColumnAttribute() { NDOMapping mapping = NDOMapping.Create(null); var cls = mapping.AddStandardClass("TestClass", "TestAssembly", null); Assert.AreEqual("ID", cls.Oid.OidColumns.First().Name); var attr = new OidColumnAttribute() { Name = "newColumnName", IsAssemblyWideDefinition = true }; cls.Oid.RemapOidColumns(new[] { attr }); Assert.AreEqual("ID", cls.Oid.OidColumns.First().Name); }
public void RemapOidColumnsWorks() { NDOMapping mapping = NDOMapping.Create(null); var cls = mapping.AddStandardClass("TestClass", "TestAssembly", null); Assert.AreEqual("ID", cls.Oid.OidColumns.First().Name); var attr = new OidColumnAttribute() { Name = "newColumnName" }; cls.Oid.RemapOidColumns(new[] { attr }); Assert.AreEqual("newColumnName", cls.Oid.OidColumns.First().Name); }
public void RemapForeignKeyColumnsWorks() { NDOMapping mapping = NDOMapping.Create(null); var cls = mapping.AddStandardClass("TestClass", "TestAssembly", null); mapping.AddStandardClass("RefTypeName", "TestAssembly", null); var relation = cls.AddStandardRelation("relField", "RefTypeName", false, "", false, false); Assert.AreEqual("IDTestClass", relation.ForeignKeyColumns.First().Name); var attr = new ForeignKeyColumnAttribute() { Name = "newColumnName" }; relation.RemapForeignKeyColumns(new[] { attr }, new ChildForeignKeyColumnAttribute[] { }); Assert.AreEqual("newColumnName", relation.ForeignKeyColumns.First().Name); }
public void MappingTableAttributeWorks() { NDOMapping mapping = NDOMapping.Create(null); var cls = mapping.AddStandardClass("TestClass", "TestAssembly", null); var relation = cls.AddStandardRelation("relField", "RefTypeName", false, "", false, false); Assert.AreEqual("IDTestClass", relation.ForeignKeyColumns.First().Name); var attr = new MappingTableAttribute(); relation.RemapMappingTable(false, false, attr); Assert.That(relation.MappingTable != null); Assert.AreEqual("relRefTypeNameTestClass", relation.MappingTable.TableName); Assert.AreEqual("IDTestClass", relation.ForeignKeyColumns.First().Name); Assert.AreEqual("IDRefTypeName", relation.MappingTable.ChildForeignKeyColumns.First().Name); attr.TableName = "newTableName"; relation.RemapMappingTable(false, false, attr); Assert.AreEqual("newTableName", relation.MappingTable.TableName); }
public void Anlegen1to1Relation() { string testFile = "Test.Xml"; NDOMapping mapping = NDOMapping.Create(testFile); Class c = mapping.AddStandardClass(classMitarbeiter, assName, null); c.AddStandardRelation("dieReise", "Reise", true, "", false, false); mapping.Save(); mapping = new NDOMapping(testFile); Assert.AreEqual(1, mapping.Connections.Count, "Keine Connection"); Assert.AreEqual(1, mapping.Classes.Count, "Keine Klasse"); c = (Class)mapping.Classes[0]; Assert.AreEqual("Mitarbeiter", c.TableName, "TableName falsch"); Assert.NotNull(c.Oid, "Keine Oid"); Assert.AreEqual(1, c.Relations.Count, "Keine Relation"); Relation r = (Relation)c.Relations[0]; Assert.AreEqual("dieReise", r.FieldName, "FieldName falsch"); Assert.AreEqual("1:1", r.GetRelationType(), "Relationstyp falsch"); Assert.AreEqual("IDReise", ((ForeignKeyColumn)r.ForeignKeyColumns[0]).Name, "ForeignKeyColumnName falsch"); }
public void GleicherKlassenName() { string testFile = "Text.Xml"; string newclassMitarbeiter = classMitarbeiter.Replace("Personal", "Test"); NDOMapping mapping = NDOMapping.Create(testFile); mapping.AddStandardClass(classMitarbeiter, assName, null); mapping.AddStandardClass(newclassMitarbeiter, assName, null); mapping.Save(); mapping = new NDOMapping(testFile); Class c = mapping.FindClass(classMitarbeiter); Assert.NotNull(c, classMitarbeiter + " nicht gefunden"); Class c2 = mapping.FindClass(newclassMitarbeiter); Assert.NotNull(c, newclassMitarbeiter + " nicht gefunden"); Assert.That(c.TableName != c2.TableName, "TableNames mössen ungleich sein"); }
public void AnlegenKlasse() { NDOMapping mapping = NDOMapping.Create(testFile); mapping.AddStandardClass(classMitarbeiter, assName, null); mapping.Save(); mapping = new NDOMapping(testFile); Assert.AreEqual(1, mapping.Connections.Count, "Keine Connection"); Assert.AreEqual(1, mapping.Classes.Count, "Keine Klasse"); Class c = (Class)mapping.Classes[0]; Assert.AreEqual("Mitarbeiter", c.TableName, "TableName falsch"); Assert.NotNull(c.Oid, "Keine Oid"); Assert.AreEqual("C0", mapping.FindConnection(c).ID, "Connection C0 nicht gefunden"); c = mapping.FindClass(classMitarbeiter); Assert.NotNull(c, "FindClass fehlgeschlagen"); File.Delete(testFile); }
public void AnlegenField() { string testFile = "Test.Xml"; NDOMapping mapping = NDOMapping.Create(testFile); Class c = mapping.AddStandardClass(classMitarbeiter, assName, null); c.AddStandardField("vorname", false); mapping.Save(); mapping = new NDOMapping(testFile); Assert.AreEqual(1, mapping.Connections.Count, "Keine Connection"); Assert.AreEqual(1, mapping.Classes.Count, "Keine Klasse"); c = (Class)mapping.Classes[0]; Assert.AreEqual("Mitarbeiter", c.TableName, "TableName falsch"); Assert.NotNull(c.Oid, "Keine Oid"); Assert.AreEqual(1, c.Fields.Count, "Kein Field"); Field f = (Field)c.Fields[0]; Assert.AreEqual("Vorname", f.Column.Name, "ColumnName falsch"); }