public void Test_GetBusinessObjectForProp_ID_WithDatabase() { ClassDef.ClassDefs.Clear(); TestUsingDatabase.SetupDBDataAccessor(); BOWithIntID.DeleteAllBOWithIntID(); IClassDef autoIncClassDef = BOWithIntID.LoadClassDefWithIntID(); IBusinessObject businessObject = GetBusinessObjectStub(); BOPropLookupList boProp = (BOPropLookupList)businessObject.Props[_propDef_int.PropertyName]; BOWithIntID bo1 = new BOWithIntID { TestField = "PropValue", IntID = 55 }; object expectedID = bo1.IntID; bo1.Save(); //---------------Assert Precondition---------------- Assert.AreEqual(typeof(int), _propDef_int.PropertyType); Assert.IsNull(boProp.Value); Assert.IsFalse(bo1.Status.IsNew); Assert.IsNotNull(bo1.IntID); //---------------Execute Test ---------------------- boProp.Value = expectedID; IBusinessObject objectForProp = boProp.GetBusinessObjectForProp(autoIncClassDef); //---------------Test Result ----------------------- Assert.IsNotNull(objectForProp); }
public void Setup() { ClassDef.ClassDefs.Clear(); BOWithIntID.LoadClassDefWithIntID(); FixtureEnvironment.SetupInMemoryDataAccessor(); FixtureEnvironment.SetupNewIsolatedBusinessObjectManager(); }
public void Test_MutableKeyObject_TwoObjectsWithSameFieldNameAndValueAsPrimaryKey() { //---------------Set up test pack------------------- ClassDef.ClassDefs.Clear(); BOWithIntID_DifferentType.LoadClassDefWithIntID(); BOWithIntID.LoadClassDefWithIntID(); DataStoreInMemory dataStore = new DataStoreInMemory(); BORegistry.DataAccessor = new DataAccessorInMemory(dataStore); new Car(); BOWithIntID boWithIntID = new BOWithIntID(); boWithIntID.IntID = TestUtil.GetRandomInt(); boWithIntID.Save(); BOWithIntID_DifferentType intID_DifferentType = new BOWithIntID_DifferentType(); intID_DifferentType.IntID = TestUtil.GetRandomInt(); intID_DifferentType.Save(); //---------------Assert Precondition---------------- Assert.AreEqual(2, dataStore.Count); //---------------Execute Test ---------------------- // dataStore.Add(intID_DifferentType); // // in the save process the ID is updated to the persisted field values, so the hash of the ID changes // // this is why the object is removed and re-added to the BusinessObjectManager (to ensure the dictionary // // of objects is hashed on the correct, updated value. // intID_DifferentType.Save(); IBusinessObject returnedBOWitID = dataStore.AllObjects[boWithIntID.ID.ObjectID]; IBusinessObject returnedBOWitID_diffType = dataStore.AllObjects[intID_DifferentType.ID.ObjectID]; //---------------Test Result ----------------------- Assert.AreSame(boWithIntID, returnedBOWitID); Assert.AreSame(intID_DifferentType, returnedBOWitID_diffType); }
public void Test_GetBusinessObject_NewBusinessObject_NotInList_NoClassDefOverloadedMethod() { //Check Validation of lookup list does not make invalid ClassDef.ClassDefs.Clear(); BOWithIntID.LoadClassDefWithIntID(); BOPropLookupList boProp = new BOPropLookupList(_propDef_int); BOWithIntID unSavedBoWithIntID = new BOWithIntID { IntID = TestUtil.GetRandomInt(), TestField = TestUtil.GetRandomString() }; boProp.Value = unSavedBoWithIntID; //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- IBusinessObject returnedBusinessObject = boProp.GetBusinessObjectForProp(); //---------------Test Result ----------------------- Assert.AreSame(unSavedBoWithIntID, returnedBusinessObject); }
public void TestFixtureSetup() { //Code that is executed before any test is run in this class. If multiple tests // are executed then it will still only be called once. ClassDef.ClassDefs.Clear(); BOWithIntID.LoadClassDefWithIntID(); _propDef_int = new PropDef("PropName", typeof(int), PropReadWriteRule.ReadWrite, null); _validBusinessObject = new BOWithIntID { TestField = _validLookupValue }; _validIntID = 3; _validBusinessObject.IntID = _validIntID; _collection_IntId = new BusinessObjectCollection <BOWithIntID> { _validBusinessObject }; _propDef_int.LookupList = new BusinessObjectLookupListStub(typeof(BOWithIntID), _collection_IntId); }
public void Test_CreateWithValue_ClassDef() { //---------------Set up test pack------------------- ClassDef.ClassDefs.Clear(); int value = TestUtil.GetRandomInt(); IClassDef autoIncClassDef = BOWithIntID.LoadClassDefWithIntID(); BOWithIntID bo = new BOWithIntID { TestField = "PropValue", IntID = value }; object expectedID = bo.ID; //---------------Execute Test ---------------------- BOPrimaryKey key = BOPrimaryKey.CreateWithValue((ClassDef)autoIncClassDef, value); //---------------Test Result ----------------------- Assert.AreEqual(expectedID.ToString(), key.ToString()); //---------------Tear Down ------------------------- }
public void Test_GetBusinessObject_SavedBusinessObject_NotInList() { //Assert.Fail("Not yet implemented"); //Check Validation of lookup list does not make invalid ClassDef.ClassDefs.Clear(); IClassDef classDefWithIntID = BOWithIntID.LoadClassDefWithIntID(); BOPropLookupList boProp = new BOPropLookupList(_propDef_int); BOWithIntID unSavedBoWithIntID = new BOWithIntID { IntID = TestUtil.GetRandomInt(), TestField = TestUtil.GetRandomString() }; unSavedBoWithIntID.Save(); FixtureEnvironment.ClearBusinessObjectManager(); boProp.Value = unSavedBoWithIntID; //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- IBusinessObject returnedBusinessObject = boProp.GetBusinessObjectForProp(classDefWithIntID); //---------------Test Result ----------------------- Assert.AreSame(unSavedBoWithIntID, returnedBusinessObject); }
public void Test_InMemoryLoader_LoadWithIntID() { ClassDef.ClassDefs.Clear(); IClassDef autoIncClassDef = BOWithIntID.LoadClassDefWithIntID(); BOWithIntID bo1 = new BOWithIntID { TestField = "PropValue", IntID = 55 }; bo1.Save(); IPrimaryKey id = bo1.ID; //---------------Assert Precondition---------------- Assert.IsFalse(bo1.Status.IsNew); Assert.IsNotNull(bo1.IntID); //---------------Execute Test ---------------------- BOWithIntID returnedBO = (BOWithIntID)BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject (autoIncClassDef, id); //---------------Test Result ----------------------- Assert.IsNotNull(returnedBO); }