public void Test_BusinessObject_WhenSet_HavingExistingNonSingleRelationshipOnRelatedBO_ShouldThrowError() { //---------------Set up test pack------------------- ClassDef.ClassDefs.Clear(); AddressTestBO.LoadDefaultClassDef(); IClassDef contactPersonClassDef = ContactPersonTestBO.LoadClassDefWithAddressesRelationship_DeleteRelated(); ContactPersonTestBO contactPersonTestBO = new ContactPersonTestBO(); const string innerRelationshipName = "ContactPersonTestBO"; const string outerRelationshipName = "Addresses"; const string relationshipName = outerRelationshipName + "." + innerRelationshipName; BORelationshipMapper boRelationshipMapper = new BORelationshipMapper(relationshipName); //---------------Assert Precondition---------------- Assert.IsNull(boRelationshipMapper.BusinessObject); Assert.IsNull(boRelationshipMapper.Relationship); //---------------Execute Test ---------------------- try { boRelationshipMapper.BusinessObject = contactPersonTestBO; Assert.Fail("Expected to throw a HabaneroDeveloperException"); } //---------------Test Result ----------------------- catch (HabaneroDeveloperException ex) { StringAssert.Contains("The relationship '" + outerRelationshipName + "' on '" + contactPersonClassDef.ClassName + "' is not a Single Relationship. Please contact your system administrator.", ex.Message); StringAssert.Contains("The relationship '" + outerRelationshipName + "' on the BusinessObject '" + contactPersonClassDef.ClassNameFull + "' is not a Single Relationship therefore cannot be traversed.", ex.DeveloperMessage); Assert.IsNull(boRelationshipMapper.BusinessObject); Assert.IsNull(boRelationshipMapper.Relationship); } }
public void SetupTest() { ClassDef.ClassDefs.Clear(); GlobalRegistry.UIExceptionNotifier = new RethrowingExceptionNotifier(); BORegistry.DataAccessor = new DataAccessorInMemory(); AddressTestBO.LoadDefaultClassDef(); ContactPersonTestBO.LoadClassDefOrganisationTestBORelationship_MultipleReverse(); OrganisationTestBO.LoadDefaultClassDef(); }
public void TestFixtureSetup() { ClassDef.ClassDefs.Clear(); GlobalRegistry.UIExceptionNotifier = new RethrowingExceptionNotifier(); FixtureEnvironment.SetupInMemoryDataAccessor(); FixtureEnvironment.ResetBORegistryBusinessObjectManager(); AddressTestBO.LoadDefaultClassDef(); ContactPersonTestBO.LoadClassDefOrganisationTestBORelationship_MultipleReverse(); OrganisationTestBO.LoadDefaultClassDef(); }
public void Test_EditDataTable_WhenMultipleLevelProp_ShouldEditRelatedBO() { //---------------Set up test pack------------------- RecordingExceptionNotifier recordingExceptionNotifier = new RecordingExceptionNotifier(); GlobalRegistry.UIExceptionNotifier = recordingExceptionNotifier; AddressTestBO.LoadDefaultClassDef(); ContactPersonTestBO.LoadClassDefWithOrganisationAndAddressRelationships(); OrganisationTestBO.LoadDefaultClassDef(); BusinessObjectCollection <AddressTestBO> addresses = new BusinessObjectCollection <AddressTestBO>(); addresses.Add(new AddressTestBO { ContactPersonTestBO = new ContactPersonTestBO() }); addresses.Add(new AddressTestBO { ContactPersonTestBO = new ContactPersonTestBO() }); addresses.Add(new AddressTestBO { ContactPersonTestBO = new ContactPersonTestBO() }); OrganisationTestBO organisation = new OrganisationTestBO(); UIGrid uiGrid = new UIGrid(); const string propertyName = "ContactPersonTestBO.OrganisationID"; uiGrid.Add(new UIGridColumn("Contact Organisation", propertyName, typeof(DataGridViewTextBoxColumn), true, 100, PropAlignment.left, new Hashtable())); IDataSetProvider dataSetProvider = CreateDataSetProvider(addresses); DataTable table = dataSetProvider.GetDataTable(uiGrid); //---------------Assert Precondition---------------- Assert.IsTrue(dataSetProvider is EditableDataSetProvider); Assert.AreEqual(3, table.Rows.Count); Assert.AreEqual(DBNull.Value, table.Rows[0][propertyName]); //---------------Execute Test ---------------------- table.Rows[0][propertyName] = organisation.OrganisationID; //---------------Test Result ----------------------- Assert.AreEqual(organisation.OrganisationID, table.Rows[0][propertyName]); Assert.AreEqual(organisation.OrganisationID, addresses[0].ContactPersonTestBO.OrganisationID); recordingExceptionNotifier.RethrowRecordedException(); }
public void Test_EditDataTable_WhenVirtualProp_ShouldEditRelatedVirtualProp() { //---------------Set up test pack------------------- RecordingExceptionNotifier recordingExceptionNotifier = new RecordingExceptionNotifier(); GlobalRegistry.UIExceptionNotifier = recordingExceptionNotifier; AddressTestBO.LoadDefaultClassDef(); var contactPersonClassDef = ContactPersonTestBO.LoadClassDefWithOrganisationAndAddressRelationships(); OrganisationTestBO.LoadDefaultClassDef(); BusinessObjectCollection <ContactPersonTestBO> contactPersonTestBOS = new BusinessObjectCollection <ContactPersonTestBO>(); contactPersonTestBOS.Add(new ContactPersonTestBO(), new ContactPersonTestBO(), new ContactPersonTestBO()); OrganisationTestBO organisation = new OrganisationTestBO(); UIGrid uiGrid = new UIGrid(); new UIDef("fdafdas", new UIForm(), uiGrid) { ClassDef = contactPersonClassDef }; const string propertyName = "-Organisation-"; uiGrid.Add(new UIGridColumn("Contact Organisation", propertyName, typeof(DataGridViewTextBoxColumn), true, 100, PropAlignment.left, new Hashtable())); IDataSetProvider dataSetProvider = CreateDataSetProvider(contactPersonTestBOS); DataTable table = dataSetProvider.GetDataTable(uiGrid); //---------------Assert Precondition---------------- Assert.IsTrue(dataSetProvider is EditableDataSetProvider); Assert.AreEqual(3, table.Rows.Count); Assert.AreEqual(DBNull.Value, table.Rows[0][propertyName]); Assert.AreEqual(null, contactPersonTestBOS[0].Organisation); //---------------Execute Test ---------------------- table.Rows[0][propertyName] = organisation; //---------------Test Result ----------------------- Assert.AreSame(organisation, table.Rows[0][propertyName]); Assert.AreSame(organisation, contactPersonTestBOS[0].Organisation); recordingExceptionNotifier.RethrowRecordedException(); }