public void Test_GetBusinessObjectFromObjectManager_IdInObjectManager_ButWrongType() { //---------------Set up test pack------------------- ClassDef.ClassDefs.Clear(); BORegistry.DataAccessor = new DataAccessorInMemory(); BOWithIntID.LoadClassDefWithIntID(); BOWithIntID_DifferentType.LoadClassDefWithIntID(); PropDef propDef = new PropDef("PropName", typeof(int), PropReadWriteRule.ReadWrite, null); BOWithIntID expectedBO = new BOWithIntID { IntID = 3, TestField = "ValidValue" }; expectedBO.Save(); propDef.LookupList = new BusinessObjectLookupList(typeof(BOWithIntID_DifferentType)); //---------------Assert Precondition---------------- Assert.AreEqual(1, BORegistry.BusinessObjectManager.Count); //---------------Execute Test ---------------------- IBusinessObject returnedBO = propDef.GetlookupBusinessObjectFromObjectManager(expectedBO.IntID); //---------------Test Result ----------------------- Assert.IsNull(returnedBO); }
public void Test_GetBusinessObjectFromObjectManager_WriteNewProp() { //---------------Set up test pack------------------- FixtureEnvironment.ClearBusinessObjectManager(); ClassDef.ClassDefs.Clear(); BORegistry.DataAccessor = new DataAccessorInMemory(); ContactPersonTestBO.LoadClassDefWithSurnameAsPrimaryKey_WriteNew(); ContactPersonTestBO contactPersonTestBO = new ContactPersonTestBO(); string surname = TestUtil.GetRandomString(); contactPersonTestBO.Surname = surname; PropDef propDef = new PropDef("PropName", typeof(string), PropReadWriteRule.ReadWrite, null); propDef.LookupList = new BusinessObjectLookupList(typeof(ContactPersonTestBO)); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- IBusinessObject returnedBO = propDef.GetlookupBusinessObjectFromObjectManager(contactPersonTestBO.Surname); //---------------Test Result ----------------------- Assert.AreSame(contactPersonTestBO, returnedBO); }
public void Test_GetBusinessObjectFromObjectManager() { //---------------Set up test pack------------------- FixtureEnvironment.ClearBusinessObjectManager(); ClassDef.ClassDefs.Clear(); BORegistry.DataAccessor = new DataAccessorInMemory(); BOWithIntID.LoadClassDefWithIntID(); PropDef propDef = new PropDef("PropName", typeof(int), PropReadWriteRule.ReadWrite, null); BOWithIntID expectedBO = new BOWithIntID { IntID = 3, TestField = "ValidValue" }; expectedBO.Save(); propDef.LookupList = new BusinessObjectLookupList(typeof(BOWithIntID)); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- IBusinessObject returnedBO = propDef.GetlookupBusinessObjectFromObjectManager(expectedBO.IntID); //---------------Test Result ----------------------- Assert.AreSame(expectedBO, returnedBO ); }