public static ClassDef CreateClassDef() { PropDefCol lPropDefCol = new PropDefCol(); PropDef propDef = new PropDef("ShapeName", typeof (String), PropReadWriteRule.ReadWrite, "ShapeName", null); lPropDefCol.Add(propDef); propDef = new PropDef("ShapeID", typeof(Guid), PropReadWriteRule.WriteOnce, "ShapeID_field", null); lPropDefCol.Add(propDef); // propDef = new PropDef("MyID", typeof(Guid), PropReadWriteRule.WriteOnce, null); // lPropDefCol.Add(propDef); PrimaryKeyDef primaryKey = new PrimaryKeyDef(); primaryKey.IsGuidObjectID = true; primaryKey.Add(lPropDefCol["ShapeID"]); KeyDefCol keysCol = new KeyDefCol(); KeyDef lKeyDef = new KeyDef(); lKeyDef.Add(lPropDefCol["ShapeName"]); keysCol.Add(lKeyDef); // RelKeyDef relKeyDef = new RelKeyDef(); //RelPropDef lRelPropDef = new RelPropDef(propDef, "OwnerID"); //relKeyDef.Add(lRelPropDef); //RelationshipDef relDef = new MultipleRelationshipDef("Owner", typeof (Shape), // relKeyDef, false, "", DeleteParentAction.DereferenceRelated); RelationshipDefCol relDefCol = new RelationshipDefCol(); //relDefCol.Add(relDef); ClassDef lClassDef = new ClassDef(typeof (Shape), primaryKey, "Shape_table", lPropDefCol, keysCol, relDefCol); ClassDef.ClassDefs.Add(lClassDef); return lClassDef; }
private static ClassDef CreateClassDef() { PropDefCol lPropDefCol = CreateBOPropDef(); var keysCol = new KeyDefCol(); var primaryKey = new PrimaryKeyDef { IsGuidObjectID = false }; primaryKey.Add(lPropDefCol[PK1_PROP1_NAME]); primaryKey.Add(lPropDefCol[PK1_PROP2_NAME]); var relDefs = new RelationshipDefCol(); var lClassDef = new ClassDef(typeof(BOWithCompositePK), primaryKey, lPropDefCol, keysCol, relDefs); ClassDef.ClassDefs.Add(lClassDef); return lClassDef; }
private static ClassDef CreateClassDef() { PropDefCol lPropDefCol = CreateBOPropDef(); KeyDefCol keysCol = new KeyDefCol(); PrimaryKeyDef primaryKey = new PrimaryKeyDef {IsGuidObjectID = false}; primaryKey.Add(lPropDefCol[PK1_PROP1_NAME]); primaryKey.Add(lPropDefCol[PK1_PROP2_NAME]); RelationshipDefCol relDefs = CreateRelationshipDefCol(lPropDefCol); ClassDef lClassDef = new ClassDef(typeof (ContactPersonCompositeKey), primaryKey, lPropDefCol, keysCol, relDefs); ClassDef.ClassDefs.Add(lClassDef); return lClassDef; }
private static ClassDef CreateClassDef() { PropDefCol propDefCol = CreateBOPropDef(); KeyDefCol keysCol = new KeyDefCol(); PrimaryKeyDef primaryKey = new PrimaryKeyDef(); primaryKey.IsGuidObjectID = true; primaryKey.Add(propDefCol["AddressID"]); RelationshipDefCol relDefCol = CreateRelationshipDefCol(propDefCol); ClassDef classDef = new ClassDef(typeof (Address), primaryKey, "contact_person_address", propDefCol, keysCol, relDefCol); ClassDef.ClassDefs.Add(classDef); return classDef; }
public void Test_CreatePrimaryKey_TwoPropDefs() { //---------------Set up test pack------------------- PropDef propDef1 = new PropDef("prop1", typeof(String), PropReadWriteRule.ReadWrite, null); PropDef propDef2 = new PropDef("prop2", typeof(String), PropReadWriteRule.ReadWrite, null); PrimaryKeyDef keyDef = new PrimaryKeyDef { IsGuidObjectID = false }; keyDef.Add(propDef2); keyDef.Add(propDef1); //---------------Assert Precondition---------------- Assert.AreEqual(2, keyDef.Count); //---------------Execute Test ---------------------- bool isCompositeKey = keyDef.IsCompositeKey; //---------------Test Result ----------------------- Assert.IsTrue(isCompositeKey); }
private static ClassDef CreateClassDef() { PropDefCol lPropDefCol = CreateBOPropDef(); KeyDefCol keysCol = new KeyDefCol(); PrimaryKeyDef primaryKey = new PrimaryKeyDef(); primaryKey.IsGuidObjectID = true; primaryKey.Add(lPropDefCol["EngineID"]); RelationshipDefCol relDefCol = CreateRelationshipDefCol(lPropDefCol); ClassDef lClassDef = new ClassDef(typeof (Engine), primaryKey, lPropDefCol, keysCol, relDefCol); lClassDef.TableName = "Table_Engine"; ClassDef.ClassDefs.Add(lClassDef); return lClassDef; }
private static ClassDef CreateClassDef() { PropDefCol lPropDefCol = CreateBOPropDef(); KeyDefCol keysCol = new KeyDefCol(); PrimaryKeyDef primaryKey = new PrimaryKeyDef(); primaryKey.IsGuidObjectID = true; primaryKey.Add(lPropDefCol["CarID"]); RelationshipDefCol relDefCol = CreateRelationshipDefCol(lPropDefCol); ClassDef lClassDef = new ClassDef(typeof (Car), primaryKey, "car_table", lPropDefCol, keysCol, relDefCol); ClassDef.ClassDefs.Add(lClassDef); return lClassDef; }
private new static ClassDef CreateClassDef() { PropDefCol lPropDefCol = new PropDefCol(); IPropDef propDef = new PropDef("Colour", typeof(int), PropReadWriteRule.ReadWrite, null); lPropDefCol.Add(propDef); propDef = lPropDefCol.Add("FilledCircleID", typeof(Guid), PropReadWriteRule.WriteOnce, "FilledCircleID_field", null); PrimaryKeyDef primaryKey = new PrimaryKeyDef(); primaryKey.IsGuidObjectID = true; primaryKey.Add(lPropDefCol["FilledCircleID"]); KeyDefCol keysCol = new KeyDefCol(); RelationshipDefCol relDefCol = new RelationshipDefCol(); ClassDef lClassDef = new ClassDef(typeof (FilledCircle), primaryKey, "FilledCircle_table", lPropDefCol, keysCol, relDefCol); lClassDef.SuperClassDef = new SuperClassDef(Circle.GetClassDef(), ORMapping.ConcreteTableInheritance); ClassDef.ClassDefs.Add(lClassDef); return lClassDef; }
private static BOObjectID CreateBOObjectID() { PropDef propDef1 = new PropDef("PropName1", typeof(Guid), PropReadWriteRule.ReadWrite, null); BOPropCol propCol = new BOPropCol(); propCol.Add(propDef1.CreateBOProp(false)); PrimaryKeyDef keyDef = new PrimaryKeyDef(); keyDef.IsGuidObjectID = true; keyDef.Add(propDef1); return (BOObjectID)keyDef.CreateBOKey(propCol); }
public void Test_ToString_WhenComposite_ShouldReturnConcatenatedPropNames() { //---------------Set up test pack------------------- string propertyName = TestUtil.GetRandomString(); string propName2 = TestUtil.GetRandomString(); PrimaryKeyDef keyDef = new PrimaryKeyDef { IsGuidObjectID = false }; keyDef.Add(new PropDef(propertyName, typeof(String), PropReadWriteRule.ReadWrite, null)); keyDef.Add(new PropDef(propName2, typeof(String), PropReadWriteRule.ReadWrite, null)); //---------------Assert Precondition---------------- Assert.AreEqual(2, keyDef.Count); //---------------Execute Test ---------------------- var toString = keyDef.ToString(); //---------------Test Result ----------------------- Assert.AreEqual(propertyName +"_" + propName2, toString); }
public void Test_ToString_ShouldReturnPropName() { //---------------Set up test pack------------------- const string propertyName = "prop1"; PropDef propDef1 = new PropDef(propertyName, typeof(String), PropReadWriteRule.ReadWrite, null); PrimaryKeyDef keyDef = new PrimaryKeyDef { IsGuidObjectID = false }; keyDef.Add(propDef1); //---------------Assert Precondition---------------- Assert.AreEqual(1, keyDef.Count); //---------------Execute Test ---------------------- var toString = keyDef.ToString(); //---------------Test Result ----------------------- Assert.AreEqual(propertyName, toString); }
private static ClassDef CreateClassDef() { PropDefCol lPropDefCol = CreateBOPropDef(); KeyDef lKeyDef = new KeyDef(); lKeyDef.IgnoreIfNull = true; lKeyDef.Add(lPropDefCol["PK2Prop1"]); lKeyDef.Add(lPropDefCol["PK2Prop2"]); KeyDefCol keysCol = new KeyDefCol(); keysCol.Add(lKeyDef); lKeyDef = new KeyDef(); lKeyDef.IgnoreIfNull = false; lKeyDef.Add(lPropDefCol["PK3Prop"]); keysCol.Add(lKeyDef); PrimaryKeyDef primaryKey = new PrimaryKeyDef(); primaryKey.IsGuidObjectID = true; primaryKey.Add(lPropDefCol["ContactPersonID"]); //Releationships RelationshipDefCol relDefs = CreateRelationshipDefCol(lPropDefCol); ClassDef lClassDef = new ClassDef(typeof (ContactPerson), primaryKey, "contact_person", lPropDefCol, keysCol, relDefs); ClassDef.ClassDefs.Add(lClassDef); return lClassDef; }
private static BOPrimaryKey CreatePrimaryBOKeyGuidAndString() { PropDef propDef1 = new PropDef("PropName1", typeof(Guid), PropReadWriteRule.ReadWrite, null) { ClassDef = ContactPersonTestBO.LoadDefaultClassDef()}; PropDef propDef2 = new PropDef("PropName2", typeof(string), PropReadWriteRule.ReadWrite, null) { ClassDef = propDef1.ClassDef}; BOPropCol propCol = new BOPropCol(); propCol.Add(propDef1.CreateBOProp(true)); propCol.Add(propDef2.CreateBOProp(true)); // BOPropCol propCol = new BOPropCol(); // propCol.Add(propDef1.CreateBOProp(true)); // propCol.Add(propDef2.CreateBOProp(true)); PrimaryKeyDef keyDef = new PrimaryKeyDef {IsGuidObjectID = false}; keyDef.Add(propDef1); keyDef.Add(propDef2); return (BOPrimaryKey)keyDef.CreateBOKey(propCol); }
public void Test_CreatePrimaryKey_OnePropDefs() { //---------------Set up test pack------------------- PropDef propDef1 = new PropDef("prop1", typeof(String), PropReadWriteRule.ReadWrite, null); PrimaryKeyDef keyDef = new PrimaryKeyDef { IsGuidObjectID = false }; keyDef.Add(propDef1); BOPropCol boPropCol = new BOPropCol(); boPropCol.Add(propDef1.CreateBOProp(false)); //---------------Assert Precondition---------------- Assert.AreEqual(1, keyDef.Count); //---------------Execute Test ---------------------- BOPrimaryKey boPrimaryKey = (BOPrimaryKey)keyDef.CreateBOKey(boPropCol); //---------------Test Result ----------------------- Assert.AreEqual(keyDef.Count, boPrimaryKey.Count); Assert.IsFalse(boPrimaryKey.IsCompositeKey); }
//protected override void ConstructFromClassDef(bool newObject) //{ // base.ConstructFromClassDef(newObject); // //SetTransactionLog(new TransactionLogTable("TransactionLogStub", // // "DateTimeUpdated", // // "WindowsUser", // // "LogonUser", // // "MachineName", // // "BusinessObjectTypeName", // // "CRUDAction", // // "DirtyXML")); //} private static ClassDef CreateClassDef() { PropDefCol lPropDefCol = CreateBOPropDef(); KeyDefCol keysCol = new KeyDefCol(); PrimaryKeyDef primaryKey = new PrimaryKeyDef(); primaryKey.IsGuidObjectID = true; primaryKey.Add(lPropDefCol["TransactionSequenceNo"]); ClassDef lClassDef = new ClassDef(typeof (TransactionLogStub), primaryKey, lPropDefCol, keysCol, null); ClassDef.ClassDefs.Add(lClassDef); return lClassDef; }
public static ClassDef CreateClassDefWithShapeRelationship() { PropDefCol lPropDefCol = CreateBOPropDef(); KeyDef lKeyDef = new KeyDef(); lKeyDef.IgnoreIfNull = true; lKeyDef.Add(lPropDefCol["PK2Prop1"]); lKeyDef.Add(lPropDefCol["PK2Prop2"]); KeyDefCol keysCol = new KeyDefCol(); keysCol.Add(lKeyDef); lKeyDef = new KeyDef(); lKeyDef.IgnoreIfNull = false; lKeyDef.Add(lPropDefCol["PK3Prop"]); keysCol.Add(lKeyDef); PrimaryKeyDef primaryKey = new PrimaryKeyDef(); primaryKey.IsGuidObjectID = true; primaryKey.Add(lPropDefCol["ContactPersonID"]); //Releationships RelationshipDefCol relDefs = new RelationshipDefCol(); RelKeyDef relKeyDef = new RelKeyDef(); IPropDef propDef = lPropDefCol["ContactPersonID"]; RelPropDef lRelPropDef = new RelPropDef(propDef, "OwnerId"); relKeyDef.Add(lRelPropDef); RelationshipDef relDef = new MultipleRelationshipDef("Shapes", typeof(Shape), relKeyDef, false, "", DeleteParentAction.DereferenceRelated); //relDefCol.Add(relDef1); relDefs.Add(relDef); ClassDef lClassDef = new ClassDef(typeof(ContactPerson), primaryKey, "contact_person", lPropDefCol, keysCol, relDefs); ClassDef.ClassDefs.Add(lClassDef); return lClassDef; }
public void TestConstructors() { PropDef propDef = new PropDef("prop", typeof(String), PropReadWriteRule.ReadWrite, null); PropDefCol propDefCol = new PropDefCol(); propDefCol.Add(propDef); PrimaryKeyDef primaryKeyDef = new PrimaryKeyDef(); primaryKeyDef.Add(propDef); KeyDef keyDef = new KeyDef(); keyDef.Add(propDef); KeyDefCol keyDefCol = new KeyDefCol(); keyDefCol.Add(keyDef); RelPropDef relPropDef = new RelPropDef(propDef, "relProp"); RelKeyDef relKeyDef = new RelKeyDef(); relKeyDef.Add(relPropDef); //RelationshipDef relDef = new SingleRelationshipDef("rel", new BusinessObject().GetType(), relKeyDef, true); RelationshipDefCol relDefCol = new RelationshipDefCol(); //relDefCol.Add(relDef); UIDef uiDef = new UIDef("default", null, null); UIDefCol uiDefCol = new UIDefCol(); uiDefCol.Add(uiDef); ClassDef classDef = new ClassDef("ass", "class", null, null, null, null, null); Assert.AreEqual("ass", classDef.AssemblyName); Assert.AreEqual("class", classDef.ClassName); Assert.AreEqual("class", classDef.TableName); Assert.IsNull(classDef.PrimaryKeyDef); Assert.IsNull(classDef.PropDefcol); Assert.IsNull(classDef.KeysCol); Assert.IsNull(classDef.RelationshipDefCol); Assert.AreEqual(0, classDef.UIDefCol.Count); classDef = new ClassDef("ass", "class", primaryKeyDef, propDefCol, keyDefCol, relDefCol, uiDefCol); Assert.AreEqual("ass", classDef.AssemblyName); Assert.AreEqual("class", classDef.ClassName); Assert.AreEqual("class", classDef.TableName); Assert.AreEqual(1, classDef.PrimaryKeyDef.Count); Assert.AreEqual(1, classDef.PropDefcol.Count); Assert.AreEqual(1, classDef.KeysCol.Count); Assert.AreEqual(0, classDef.RelationshipDefCol.Count); Assert.AreEqual(1, classDef.UIDefCol.Count); classDef = new ClassDef(typeof(String), primaryKeyDef, "table", propDefCol, keyDefCol, relDefCol, uiDefCol); //Assert.AreEqual("db", classDef.); ? database has no usage Assert.AreEqual(typeof(String), classDef.ClassType); Assert.AreEqual("table", classDef.TableName); Assert.AreEqual(1, classDef.PrimaryKeyDef.Count); Assert.AreEqual(1, classDef.PropDefcol.Count); Assert.AreEqual(1, classDef.KeysCol.Count); Assert.AreEqual(0, classDef.RelationshipDefCol.Count); Assert.AreEqual(1, classDef.UIDefCol.Count); classDef = new ClassDef(typeof(String), primaryKeyDef, "table", propDefCol, keyDefCol, relDefCol); //Assert.AreEqual("db", classDef.); ? database has no usage Assert.AreEqual(typeof(String), classDef.ClassType); Assert.AreEqual("table", classDef.TableName); Assert.AreEqual(1, classDef.PrimaryKeyDef.Count); Assert.AreEqual(1, classDef.PropDefcol.Count); Assert.AreEqual(1, classDef.KeysCol.Count); Assert.AreEqual(0, classDef.RelationshipDefCol.Count); Assert.AreEqual(0, classDef.UIDefCol.Count); classDef = new ClassDef(typeof(String), primaryKeyDef, propDefCol, keyDefCol, relDefCol, uiDefCol); //Assert.AreEqual("db", classDef.); ? database has no usage Assert.AreEqual(typeof(String), classDef.ClassType); Assert.AreEqual("String", classDef.TableName); Assert.AreEqual(1, classDef.PrimaryKeyDef.Count); Assert.AreEqual(1, classDef.PropDefcol.Count); Assert.AreEqual(1, classDef.KeysCol.Count); Assert.AreEqual(0, classDef.RelationshipDefCol.Count); Assert.AreEqual(1, classDef.UIDefCol.Count); classDef = new ClassDef(typeof(String), primaryKeyDef, "table", propDefCol, keyDefCol, relDefCol, uiDefCol); //Assert.AreEqual("db", classDef.); ? database has no usage Assert.AreEqual(typeof(String), classDef.ClassType); Assert.AreEqual("table", classDef.TableName); Assert.AreEqual(1, classDef.PrimaryKeyDef.Count); Assert.AreEqual(1, classDef.PropDefcol.Count); Assert.AreEqual(1, classDef.KeysCol.Count); Assert.AreEqual(0, classDef.RelationshipDefCol.Count); Assert.AreEqual(1, classDef.UIDefCol.Count); }
private static PrimaryKeyDef CreatePrimaryKey(PropDefCol lPropDefCol) { PrimaryKeyDef primaryKey = new PrimaryKeyDef(); primaryKey.IsGuidObjectID = false; primaryKey.Add(lPropDefCol["Surname"]); primaryKey.Add(lPropDefCol["FirstName"]); primaryKey.Add(lPropDefCol["DateOfBirth"]); return primaryKey; }
private static ClassDef CreateClassDef() { PropDefCol lPropDefCol = CreateBOPropDef(); KeyDefCol keysCol = new KeyDefCol(); PrimaryKeyDef primaryKey = new PrimaryKeyDef(); primaryKey.IsGuidObjectID = true; primaryKey.Add(lPropDefCol["MockBOID"]); ClassDef lClassDef = new ClassDef (typeof (MockBOWithCompulsoryField), primaryKey, lPropDefCol, keysCol, new RelationshipDefCol()); ClassDef.ClassDefs.Add(lClassDef); return lClassDef; }
private static ClassDef CreateClassDef() { PropDefCol lPropDefCol = new PropDefCol(); IPropDef propDef = new PropDef("FakeSuperClassID", typeof(Guid), PropReadWriteRule.WriteOnce, null); lPropDefCol.Add(propDef); PrimaryKeyDef primaryKey = new PrimaryKeyDef {IsGuidObjectID = true}; primaryKey.Add(lPropDefCol["FakeSuperClassID"]); KeyDefCol keysCol = new KeyDefCol(); RelationshipDefCol relDefCol = new RelationshipDefCol(); ClassDef lClassDef = new ClassDef(typeof(FakeSuperClass), primaryKey, lPropDefCol, keysCol, relDefCol, null); ClassDef.ClassDefs.Add(lClassDef); return lClassDef; }
private static ClassDef CreateClassDef() { PropDefCol lPropDefCol = new PropDefCol(); lPropDefCol.Add( new PropDef("SampleText", typeof (String), PropReadWriteRule.ReadWrite, "SampleText", null)); lPropDefCol.Add( new PropDef("SampleText2", typeof(String), PropReadWriteRule.ReadWrite, "SampleText2", null)); lPropDefCol.Add( new PropDef("SampleTextPrivate", typeof(String), PropReadWriteRule.ReadWrite, "SampleTextPrivate", null, false, false, int.MaxValue, null, null, true)); lPropDefCol.Add( new PropDef("SampleTextDescribed", typeof(String), PropReadWriteRule.ReadWrite, "SampleTextDescribed", null, false, false, int.MaxValue, null, "This is a sample text property that has a description.", false)); lPropDefCol.Add( new PropDef("SampleDate", typeof(DateTime), PropReadWriteRule.ReadWrite, "SampleDate", null)); lPropDefCol.Add( new PropDef("SampleDateNullable", typeof(DateTime), PropReadWriteRule.ReadWrite, "SampleDate", null)); lPropDefCol.Add( new PropDef("SampleBoolean", typeof (Boolean), PropReadWriteRule.ReadWrite, "SampleBoolean", null)); lPropDefCol.Add( new PropDef("SampleLookupID", typeof (Guid), PropReadWriteRule.ReadWrite, "SampleLookupID", null)); lPropDefCol.Add( new PropDef("SampleInt", typeof (int), PropReadWriteRule.ReadWrite, "SampleInt", 0)); lPropDefCol.Add( new PropDef("SampleMoney", typeof (Decimal), PropReadWriteRule.ReadWrite, "SampleInt", new Decimal(0))); PropDef propDef = new PropDef("SampleLookup2ID", typeof (Guid), PropReadWriteRule.ReadWrite, "SampleLookup2ID", null); itsLookupCollection = new Dictionary<string, string>(); itsLookupCollection.Add("Test1", new Guid("{6E8B3DDB-1B13-4566-868D-57478C1F4BEE}").ToString()); itsLookupCollection.Add("Test2",new Guid("{7209B956-96A0-4720-8E49-DE154FA0E096}").ToString()); itsLookupCollection.Add("Test3", new Guid("{F45DE850-C693-44d8-AC39-8CEE5435B21A}").ToString()); propDef.LookupList = new SimpleLookupList(itsLookupCollection); lPropDefCol.Add(propDef); lPropDefCol.Add(new PropDef("SampleLookup3ID", typeof (String), PropReadWriteRule.ReadWrite, "SampleLookup3ID", null)); PropDef def = new PropDef("SampleID", typeof (Guid), PropReadWriteRule.WriteOnce, null); lPropDefCol.Add(def); PrimaryKeyDef primaryKey = new PrimaryKeyDef(); primaryKey.IsGuidObjectID = true; primaryKey.Add(lPropDefCol["SampleID"]); KeyDefCol keysCol = new KeyDefCol(); RelationshipDefCol relDefCol = new RelationshipDefCol(); return new ClassDef(typeof (Sample), primaryKey, lPropDefCol, keysCol, relDefCol); }