public void Test_Add_PersistedBO() { //---------------Set up test pack------------------- //The persisted business objects should not be added since this is a normal cpCollection which does not // modify the added objects alternate key etc unlike the RelatedBusinessObjectCollection BusinessObjectCollection <ContactPersonTestBO> cpCol = new BusinessObjectCollection <ContactPersonTestBO>(); ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson(); ContactPersonTestBO myBO2 = ContactPersonTestBO.CreateSavedContactPerson(); ContactPersonTestBO myBO3 = ContactPersonTestBO.CreateSavedContactPerson(); _businessObjectCollectionTestHelper.RegisterForAddedEvent(cpCol); //-------Assert Preconditions Assert.AreEqual(0, cpCol.Count, "Three objects should be in the cpCollection"); ///---------------Execute Test ---------------------- cpCol.Add(myBO, myBO2, myBO3); //---------------Test Result ----------------------- - Result Assert.AreEqual(3, cpCol.Count, "Three objects should be in the copied cpCollection"); Assert.AreEqual (3, cpCol.AddedBusinessObjects.Count, "The persisted business objects should not be in the AddedList since this is a normal cpCollection which does not modify the added objects alternate key etc unlike the RelatedBusinessObjectCollection"); _businessObjectCollectionTestHelper.AssertAddedEventFired(); }
public void Test_MarkForDelete_Added_RestoreBO_LoadWCriteria() { //---------------Set up test pack------------------- BusinessObjectCollection <ContactPersonTestBO> cpCol = new BusinessObjectCollection <ContactPersonTestBO>(); cpCol.Load("Surname=cc", ""); ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson("BB"); cpCol.Add(myBO); myBO.MarkForDelete(); _businessObjectCollectionTestHelper.RegisterForAddedAndRemovedEvents(cpCol); //---------------Assert Precondition---------------- BusinessObjectCollectionTestHelper.AssertOneObjectInMarkForDeleteAndAddedCollection(cpCol); Assert.IsTrue(myBO.Status.IsDirty); //---------------Execute Test ---------------------- myBO.CancelEdits(); //---------------Test Result ----------------------- BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndAddedCollection(cpCol); Assert.IsFalse(myBO.Status.IsDirty); _businessObjectCollectionTestHelper.AssertAddedEventFired(); _businessObjectCollectionTestHelper.AssertRemovedEventNotFired(); }
public void Test_UpdateStateAsCommitted_Removed_UpdatesCols() { //---------------Set up test pack------------------- ContactPersonTestBO contactPersonTestBO = ContactPersonTestBO.CreateSavedContactPerson(); OrganisationTestBO organisationTestBO = new OrganisationTestBO(); SingleRelationship <OrganisationTestBO> singleRelationship = contactPersonTestBO.Relationships.GetSingle <OrganisationTestBO>("Organisation"); BusinessObjectCollection <ContactPersonTestBO> people = organisationTestBO.ContactPeople; organisationTestBO.Save(); contactPersonTestBO.Organisation = organisationTestBO; contactPersonTestBO.Save(); contactPersonTestBO.Organisation = null; IRelationship relationship = organisationTestBO.Relationships.GetMultiple <ContactPersonTestBO>("ContactPeople"); TransactionalSingleRelationship_Removed tsr = new TransactionalSingleRelationship_Removed(relationship, contactPersonTestBO); //---------------Assert PreConditions--------------- Assert.AreEqual(1, people.RemovedBusinessObjects.Count); Assert.AreEqual(1, people.PersistedBusinessObjects.Count); Assert.IsTrue(singleRelationship.IsRemoved); //---------------Execute Test ---------------------- tsr.UpdateStateAsCommitted(); //---------------Test Result ----------------------- Assert.AreEqual(0, people.RemovedBusinessObjects.Count); Assert.AreEqual(0, people.PersistedBusinessObjects.Count); // Assert.IsFalse(singleRelationship.IsRemoved); //---------------Tear Down ------------------------- }
public void TestGetBusinessObject_MultipleCriteria() { //---------------Set up test pack------------------- ClassDef.ClassDefs.Clear(); SetupDefaultContactPersonBO(); BORegistry.BusinessObjectManager = new BusinessObjectManagerSpy();//Ensures a new BOMan is created and used for each test const string surname = "abc"; const string firstName = "aa"; ContactPersonTestBO.CreateSavedContactPerson("ZZ", "zzz"); ContactPersonTestBO savedContactPerson = ContactPersonTestBO.CreateSavedContactPerson (surname, firstName); ContactPersonTestBO.CreateSavedContactPerson("aaaa", "aaa"); //---------------Execute Test ---------------------- Criteria criteria1 = new Criteria("Surname", Criteria.ComparisonOp.Equals, surname); Criteria criteria2 = new Criteria("FirstName", Criteria.ComparisonOp.Equals, firstName); Criteria criteria = new Criteria(criteria1, Criteria.LogicalOp.And, criteria2); ContactPersonTestBO cp = BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject <ContactPersonTestBO>(criteria); //---------------Test Result ----------------------- Assert.AreSame(savedContactPerson, cp); Assert.AreEqual(surname, cp.Surname); Assert.AreEqual(firstName, cp.FirstName); Assert.IsFalse(cp.Status.IsNew); Assert.IsFalse(cp.Status.IsDirty); Assert.IsFalse(cp.Status.IsDeleted); }
public void Test_UpdateSqlStatement() { //---------------Set up test pack------------------- ContactPersonTestBO.LoadClassDefOrganisationTestBORelationship_MultipleReverse(); OrganisationTestBO.LoadDefaultClassDef(); ContactPersonTestBO contactPersonTestBO = ContactPersonTestBO.CreateSavedContactPerson(); OrganisationTestBO organisationTestBO = new OrganisationTestBO(); SingleRelationship <OrganisationTestBO> singleRelationship = contactPersonTestBO.Relationships.GetSingle <OrganisationTestBO>("Organisation"); singleRelationship.SetRelatedObject(organisationTestBO); IRelationship relationship = organisationTestBO.Relationships.GetMultiple <ContactPersonTestBO>("ContactPeople"); //TransactionalSingleRelationship_Added tsr = new TransactionalSingleRelationship_Added(singleRelationship); var generator = CreateUpdateStatementGenerator(contactPersonTestBO, DatabaseConfig.MySql); //---------------Assert PreConditions--------------- //---------------Execute Test ---------------------- var sql = generator.GenerateForRelationship(relationship, contactPersonTestBO); //---------------Test Result ----------------------- var sqlStatements = sql.ToList(); Assert.AreEqual(1, sqlStatements.Count); Assert.AreEqual("UPDATE `contact_person` SET `OrganisationID` = ?Param0 WHERE `ContactPersonID` = ?Param1", sqlStatements[0].Statement.ToString()); Assert.AreEqual(organisationTestBO.OrganisationID.Value.ToString("B").ToUpper(), sqlStatements[0].Parameters[0].Value); Assert.AreEqual(contactPersonTestBO.ContactPersonID.ToString("B").ToUpper(), sqlStatements[0].Parameters[1].Value); }
protected static ContactPersonTestBO CreateAddedChild(BusinessObjectCollection <ContactPersonTestBO> cpCol) { ContactPersonTestBO addedChild = ContactPersonTestBO.CreateSavedContactPerson(); cpCol.Add(addedChild); return(addedChild); }
public void TestGetBusinessObject_MultipleCriteria_CriteriaString_Untyped() { //---------------Set up test pack------------------- ClassDef.ClassDefs.Clear(); IClassDef classDef = SetupDefaultContactPersonBO(); BORegistry.BusinessObjectManager = new BusinessObjectManagerSpy();//Ensures a new BOMan is created and used for each test const string surname = "abc"; const string firstName = "aa"; ContactPersonTestBO.CreateSavedContactPerson("ZZ", "zzz"); ContactPersonTestBO savedContactPerson = ContactPersonTestBO.CreateSavedContactPerson (surname, firstName); ContactPersonTestBO.CreateSavedContactPerson("aaaa", "aaa"); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- ContactPersonTestBO cp = (ContactPersonTestBO) BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject (classDef, "Surname = " + surname + " AND FirstName = " + firstName); //---------------Test Result ----------------------- Assert.AreSame(savedContactPerson, cp); Assert.AreEqual(surname, cp.Surname); Assert.AreEqual(firstName, cp.FirstName); Assert.IsFalse(cp.Status.IsNew); Assert.IsFalse(cp.Status.IsDirty); Assert.IsFalse(cp.Status.IsDeleted); }
protected virtual ContactPersonTestBO CreateAddedChild_ChildOwnsEdit(OrganisationTestBO organisationTestBO) { ContactPersonTestBO addedChild = ContactPersonTestBO.CreateSavedContactPerson(); addedChild.Organisation = organisationTestBO; return(addedChild); }
public virtual void Test_AddDirtyChildrenToTransactionCommitter_AddedChild() { //---------------Set up test pack------------------- OrganisationTestBO organisationTestBO = OrganisationTestBO.CreateSavedOrganisation(); MultipleRelationship <ContactPersonTestBO> relationship = organisationTestBO.Relationships.GetMultiple <ContactPersonTestBO>("ContactPeople"); RelationshipDef relationshipDef = (RelationshipDef)relationship.RelationshipDef; relationshipDef.RelationshipType = RelationshipType.Association; ContactPersonTestBO contactPerson = ContactPersonTestBO.CreateSavedContactPerson(); relationship.BusinessObjectCollection.Add(contactPerson); SingleRelationship <OrganisationTestBO> reverseRelationship = contactPerson.Relationships.GetSingle <OrganisationTestBO>("Organisation"); TransactionCommitter tc = (TransactionCommitter)BORegistry.DataAccessor.CreateTransactionCommitter(); //---------------Assert PreConditions--------------- Assert.AreEqual(0, tc.OriginalTransactions.Count); Assert.IsNotNull(reverseRelationship); //---------------Execute Test ---------------------- relationship.AddDirtyChildrenToTransactionCommitter(tc); //---------------Test Result ----------------------- Assert.AreEqual(1, tc.OriginalTransactions.Count); Assert.IsInstanceOf(typeof(TransactionalSingleRelationship_Added), tc.OriginalTransactions[0]); Assert.AreSame(relationship, ((TransactionalSingleRelationship_Added)tc.OriginalTransactions[0]).Relationship); }
public void Test_AddMethod_AddPersistedChild() { //An already persisted invoice line cannot be added to an Invoice //(In Habanero a new invoice line can be added to an invoice). //---------------Set up test pack------------------- BusinessObjectCollection <ContactPersonTestBO> cpCol; MultipleRelationship <ContactPersonTestBO> compositionRelationship = GetCompositionRelationship(out cpCol); ContactPersonTestBO contactPerson = ContactPersonTestBO.CreateSavedContactPerson(); //---------------Assert Precondition---------------- util.AssertAllCollectionsHaveNoItems(cpCol); //---------------Execute Test ---------------------- try { cpCol.Add(contactPerson); Assert.Fail("expected Err"); } //---------------Test Result ----------------------- catch (HabaneroDeveloperException ex) { AssertMessageIsCorrect(ex, compositionRelationship.RelationshipDef.RelatedObjectClassName, "added", compositionRelationship.RelationshipName); } catch (Exception ex) { Assert.Fail("HabaneroDeveloperException not thrown. Exception Thrown was : " + ex.Message); } }
public void TestTodayDateStringCriteria_GreaterThanOrEqualTo() { //-------------Setup Test Pack ------------------ DeleteAllContactPeople(); BusinessObjectCollection <ContactPersonTestBO> myCol = new BusinessObjectCollection <ContactPersonTestBO>(); myCol.LoadAll(); DateTime today = DateTime.Today; ContactPersonTestBO.CreateSavedContactPerson(today.AddDays(-1), "aaa"); ContactPersonTestBO.CreateSavedContactPerson(today, "bbb"); ContactPersonTestBO contactPerson3 = ContactPersonTestBO.CreateSavedContactPerson(today.AddDays(1), "ccc"); //ContactPersonTestBO.ClearObjectManager(); BusinessObjectLookupList businessObjectLookupList = new BusinessObjectLookupList("Habanero.Test.BO", "ContactPersonTestBO", "DateOfBirth > 'TODAY'", ""); businessObjectLookupList.PropDef = new PropDef("name", typeof(string), PropReadWriteRule.ReadWrite, null); //-------------Test Pre-conditions -------------- Assert.AreEqual(0, myCol.Count); //-------------Execute test --------------------- Dictionary <string, string> col = businessObjectLookupList.GetLookupList(DatabaseConnection.CurrentConnection); //-------------Test Result ---------------------- Assert.AreEqual(1, col.Count); Assert.IsTrue(col.ContainsValue(GuidToString(contactPerson3.ID.GetAsGuid()))); }
public void Test_AddedChild_UpdatesRelatedPropertiesOnlyWhenParentSaves_OnlyIDChanged() { //---------------Set up test pack------------------- OrganisationTestBO organisationTestBO = OrganisationTestBO.CreateSavedOrganisation(); ContactPersonTestBO contactPerson = ContactPersonTestBO.CreateSavedContactPerson(); RelationshipDef relationshipDef = (RelationshipDef)organisationTestBO.Relationships["ContactPeople"].RelationshipDef; relationshipDef.RelationshipType = RelationshipType.Association; organisationTestBO.ContactPeople.Add(contactPerson); //---------------Assert PreConditions--------------- Assert.IsTrue(contactPerson.Status.IsDirty); Assert.IsTrue(contactPerson.Props["OrganisationID"].IsDirty); Assert.IsTrue(organisationTestBO.Status.IsDirty); //---------------Execute Test ---------------------- organisationTestBO.Save(); //---------------Test Result ----------------------- Assert.IsFalse(contactPerson.Status.IsDirty); Assert.IsFalse(contactPerson.Props["OrganisationID"].IsDirty); Assert.IsFalse(organisationTestBO.Status.IsDirty); //---------------Tear Down ------------------------- }
public virtual void Test_RemovedChild_UpdatesRelatedPropertiesOnlyWhenParentSaves() { //---------------Set up test pack------------------- OrganisationTestBO organisation = OrganisationTestBO.CreateSavedOrganisation(); SingleRelationship <ContactPersonTestBO> relationship = GetAssociationRelationship(organisation); relationship.OwningBOHasForeignKey = false; ContactPersonTestBO contactPerson = ContactPersonTestBO.CreateSavedContactPerson(); organisation.ContactPerson = contactPerson; organisation.Save(); contactPerson.Surname = TestUtil.GetRandomString(); organisation.ContactPerson = null; //---------------Assert PreConditions--------------- Assert.IsTrue(contactPerson.Status.IsDirty); Assert.IsTrue(contactPerson.Props["OrganisationID"].IsDirty); Assert.IsNull(contactPerson.Props["OrganisationID"].Value); Assert.IsTrue(organisation.Status.IsDirty); //---------------Execute Test ---------------------- organisation.Save(); //---------------Test Result ----------------------- Assert.IsTrue(contactPerson.Status.IsDirty); Assert.IsFalse(contactPerson.Props["OrganisationID"].IsDirty); Assert.IsNull(contactPerson.Props["OrganisationID"].Value); Assert.IsFalse(organisation.Status.IsDirty); }
public virtual void Test_AddedChild_UpdatesRelatedPropertiesOnlyWhenParentSaves() { //---------------Set up test pack------------------- OrganisationTestBO organisation = OrganisationTestBO.CreateSavedOrganisation(); GetAssociationRelationship(organisation); ContactPersonTestBO contactPerson = ContactPersonTestBO.CreateSavedContactPerson(); organisation.ContactPerson = contactPerson; contactPerson.Surname = TestUtil.GetRandomString(); //---------------Assert PreConditions--------------- Assert.IsTrue(contactPerson.Status.IsDirty); Assert.IsTrue(contactPerson.Props["OrganisationID"].IsDirty); Assert.IsTrue(organisation.Status.IsDirty); //---------------Execute Test ---------------------- organisation.Save(); //---------------Test Result ----------------------- Assert.IsTrue(contactPerson.Status.IsDirty); Assert.IsFalse(contactPerson.Props["OrganisationID"].IsDirty); Assert.IsFalse(organisation.Status.IsDirty); //---------------Tear Down ------------------------- }
public void TestAfterLoadCalled_GetCollection_Generic_NotReloaded() { //---------------Set up test pack------------------- BORegistry.BusinessObjectManager = new BusinessObjectManagerSpy(); SetupDefaultContactPersonBO(); ContactPersonTestBO cp = ContactPersonTestBO.CreateSavedContactPersonNoAddresses(); ContactPersonTestBO.CreateSavedContactPerson(); BORegistry.BusinessObjectManager = new BusinessObjectManagerSpy(); //---------------Assert Precondition---------------- Assert.IsFalse(cp.AfterLoadCalled); //---------------Execute Test ---------------------- Criteria criteria = new Criteria ("ContactPersonID", Criteria.ComparisonOp.Equals, cp.ContactPersonID.ToString("B")); BusinessObjectCollection <ContactPersonTestBO> col = BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObjectCollection <ContactPersonTestBO> (criteria); //---------------Test Result ----------------------- Assert.AreEqual(1, col.Count); ContactPersonTestBO loadedBO = col[0]; Assert.IsTrue(loadedBO.AfterLoadCalled); //This works because if the object is not dirty then it is refreshed from the database }
public void TestBoLoader_RefreshBusinessObjectDeletedByAnotherUser() { //-------------Setup Test Pack------------------ SetupDefaultContactPersonBO(); ContactPersonTestBO cpTemp = ContactPersonTestBO.CreateSavedContactPerson(); FixtureEnvironment.ClearBusinessObjectManager(); ContactPersonTestBO cpLoaded = BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject <ContactPersonTestBO>(cpTemp.ID); cpTemp.MarkForDelete(); cpTemp.Save(); //-------------Execute Test --------------------- try { BORegistry.DataAccessor.BusinessObjectLoader.Refresh(cpLoaded); Assert.Fail(); } //-------------Test Result --------------------- catch (BusObjDeleteConcurrencyControlException ex) { StringAssert.Contains ("A Error has occured since the object you are trying to refresh has been deleted by another user.", ex.Message); StringAssert.Contains("There are no records in the database for the Class", ex.Message); StringAssert.Contains("ContactPersonTestBO", ex.Message); StringAssert.Contains(cpLoaded.ID.ToString(), ex.Message); } }
public void Test_SetParent_AggregateDoesNotOwnForeignKey_PersistedChild() { //---------------Set up test pack------------------- OrganisationTestBO organisation = OrganisationTestBO.CreateSavedOrganisation(); ContactPersonTestBO contactPerson = ContactPersonTestBO.CreateSavedContactPerson(); GetAggregationRelationshipOrganisation(contactPerson, "Organisation"); //---------------Execute Test ---------------------- contactPerson.Organisation = organisation; //---------------Test Result ----------------------- Assert.AreSame(contactPerson, organisation.ContactPerson); Assert.AreSame(organisation, contactPerson.Organisation); }
public void Test_SetChild_PersistedChild() { //An already persisted contactperson can be set as the contact person of an organisation //---------------Set up test pack------------------- OrganisationTestBO organisationTestBO = OrganisationTestBO.CreateSavedOrganisation(); SingleRelationship <ContactPersonTestBO> relationship = GetAssociationRelationship(organisationTestBO); ContactPersonTestBO contactPerson = ContactPersonTestBO.CreateSavedContactPerson(); //---------------Execute Test ---------------------- relationship.SetRelatedObject(contactPerson); //---------------Test Result ----------------------- Assert.AreSame(contactPerson, relationship.GetRelatedObject()); }
public void Test_RemoveBusinessObject_DoesNothing() { //---------------Set up test pack------------------- ContactPersonTestBO.LoadDefaultClassDef(); IBusinessObjectManager boMan = new BusinessObjectManagerNull(); ContactPersonTestBO originalContactPerson = ContactPersonTestBO.CreateSavedContactPerson(); //---------------Assert Precondition---------------- Assert.AreEqual(0, boMan.Count); //---------------Execute Test ---------------------- boMan.Remove(originalContactPerson); //---------------Test Result ----------------------- Assert.AreEqual(0, boMan.Count); }
public void Test_SetChild_PersistedChild() { //An already persisted Heart can be set as the heart of a person (since you can transplant hearts) //---------------Set up test pack------------------- OrganisationTestBO organisationTestBO = OrganisationTestBO.CreateSavedOrganisation(); SingleRelationship <ContactPersonTestBO> relationship = GetAggregationRelationshipContactPerson(organisationTestBO, "ContactPerson"); ContactPersonTestBO contactPerson = ContactPersonTestBO.CreateSavedContactPerson(); //---------------Execute Test ---------------------- relationship.SetRelatedObject(contactPerson); //---------------Test Result ----------------------- Assert.AreSame(contactPerson, relationship.GetRelatedObject()); }
public void Test_SetParent_PersistedChild_NonPersistedParent() { //---------------Set up test pack------------------- OrganisationTestBO organisation = OrganisationTestBO.CreateUnsavedOrganisation(); GetAggregationRelationshipContactPerson(organisation, "ContactPerson"); ContactPersonTestBO contactPerson = ContactPersonTestBO.CreateSavedContactPerson(); //---------------Assert Precondition ----------------------- Assert.IsNotNull(organisation.OrganisationID); //---------------Execute Test ---------------------- contactPerson.Organisation = organisation; //---------------Test Result ----------------------- Assert.AreSame(contactPerson, organisation.ContactPerson); Assert.AreSame(organisation, contactPerson.Organisation); }
public void Test_GetDirtyChildren_AddedChild() { //---------------Set up test pack------------------- OrganisationTestBO organisationTestBO = OrganisationTestBO.CreateSavedOrganisation(); SingleRelationship <ContactPersonTestBO> relationship = GetAssociationRelationship(organisationTestBO); ContactPersonTestBO contactPerson = ContactPersonTestBO.CreateSavedContactPerson(); organisationTestBO.ContactPerson = contactPerson; //---------------Execute Test ---------------------- IList <ContactPersonTestBO> dirtyChildren = relationship.GetDirtyChildren(); //---------------Test Result ----------------------- Assert.AreEqual(0, dirtyChildren.Count); //---------------Tear Down ------------------------- }
public void Test_GetDirtyChildren_Added() { //---------------Set up test pack------------------- OrganisationTestBO organisationTestBO = OrganisationTestBO.CreateSavedOrganisation(); BusinessObjectCollection <ContactPersonTestBO> cpCol; MultipleRelationship <ContactPersonTestBO> relationship = GetAssociationRelationship (organisationTestBO, out cpCol); ContactPersonTestBO contactPerson = ContactPersonTestBO.CreateSavedContactPerson(); cpCol.Add(contactPerson); //---------------Execute Test ---------------------- IList <ContactPersonTestBO> dirtyChildren = relationship.GetDirtyChildren(); //---------------Test Result ----------------------- Assert.AreEqual(0, dirtyChildren.Count); }
public void Test_DirtyIfHasAddedChild() { //---------------Set up test pack------------------- OrganisationTestBO organisationTestBO = OrganisationTestBO.CreateSavedOrganisation(); GetAssociationRelationship(organisationTestBO); ContactPersonTestBO contactPerson = ContactPersonTestBO.CreateSavedContactPerson(); //---------------Assert Precondition---------------- Assert.IsFalse(organisationTestBO.Status.IsDirty); //---------------Execute Test ---------------------- organisationTestBO.ContactPerson = contactPerson; bool isDirty = organisationTestBO.Status.IsDirty; //---------------Test Result ----------------------- Assert.IsTrue(isDirty); }
public void Test_DirtyIfHasAddedChildren() { //---------------Set up test pack------------------- OrganisationTestBO organisationTestBO = OrganisationTestBO.CreateSavedOrganisation(); BusinessObjectCollection <ContactPersonTestBO> cpCol; MultipleRelationship <ContactPersonTestBO> aggregationRelationship = GetAggregationRelationship (organisationTestBO, out cpCol); ContactPersonTestBO contactPerson = ContactPersonTestBO.CreateSavedContactPerson(); //---------------Assert Precondition---------------- Assert.IsFalse(aggregationRelationship.IsDirty); //---------------Execute Test ---------------------- cpCol.Add(contactPerson); //---------------Test Result ----------------------- Assert.IsTrue(aggregationRelationship.IsDirty); }
public virtual void Test_IsDirty_WhenNoEditsDone_ShouldBeFalse() { //---------------Set up test pack------------------- TestBOEditorControl.GetCustomClassDef(); GlobalUIRegistry.ControlFactory = GetControlFactory(); BORegistry.DataAccessor = new DataAccessorInMemory(); ContactPersonTestBO person = ContactPersonTestBO.CreateSavedContactPerson(); IBOPanelEditorControl controlWin = CreateEditorControl(person.ClassDef); //---------------Assert Precondition---------------- Assert.IsTrue(person.Status.IsValid()); //---------------Execute Test ---------------------- controlWin.BusinessObject = person; bool dirty = controlWin.IsDirty; //---------------Test Result ----------------------- Assert.IsFalse(dirty); }
public virtual void Test_HasErrors_WhenBOValid_ShouldBeFalse() { //---------------Set up test pack------------------- TestBOEditorControl.GetCustomClassDef(); GlobalUIRegistry.ControlFactory = GetControlFactory(); BORegistry.DataAccessor = new DataAccessorInMemory(); ContactPersonTestBO person = ContactPersonTestBO.CreateSavedContactPerson(); IBOPanelEditorControl controlWin = CreateEditorControl(person.ClassDef); controlWin.BusinessObject = person; //---------------Assert Precondition---------------- Assert.IsTrue(controlWin.BusinessObject.Status.IsValid()); //---------------Execute Test ---------------------- bool hasErrors = controlWin.HasErrors; //---------------Test Result ----------------------- Assert.IsFalse(hasErrors); }
public virtual void Test_IfValidState_WhenSetControlValueToInvalidValue_ShouldUpdatesErrorProviders() { //---------------Set up test pack------------------- TestBOEditorControl.GetCustomClassDef(); GlobalUIRegistry.ControlFactory = GetControlFactory(); BORegistry.DataAccessor = new DataAccessorInMemory(); ContactPersonTestBO person = ContactPersonTestBO.CreateSavedContactPerson(); IBOPanelEditorControl controlWin = CreateEditorControl(person.ClassDef); controlWin.BusinessObject = person; //---------------Assert Precondition---------------- Assert.IsTrue(controlWin.BusinessObject.Status.IsValid()); AssertErrorProvidersHaveBeenCleared(controlWin); //---------------Execute Test ---------------------- SetSurnameTextBoxToNull(controlWin); //---------------Test Result ----------------------- AssertErrorProviderHasErrors(controlWin, "Surname"); }
public void Test_GetCount() { //---------------Set up test pack------------------- ClassDef.ClassDefs.Clear(); IClassDef classDef = ContactPersonTestBO.LoadDefaultClassDef(); FixtureEnvironment.ClearBusinessObjectManager(); TestUtil.WaitForGC(); ContactPersonTestBO.CreateSavedContactPerson("aaaa", "aaa"); ContactPersonTestBO.CreateSavedContactPerson("bbbb", "bbb"); ContactPersonTestBO.CreateSavedContactPerson("cccc", "ccc"); //-------------Assert Preconditions ------------- //---------------Execute Test ---------------------- int count = BORegistry.DataAccessor.BusinessObjectLoader.GetCount(classDef, null); //---------------Test Result ----------------------- Assert.AreEqual(3, count); }
public void Test_IfInvalidState_WhenSetBOToValidBo_ShouldClearErrorProviders() { //---------------Set up test pack------------------- TestBOEditorControl.GetCustomClassDef(); GlobalUIRegistry.ControlFactory = GetControlFactory(); BORegistry.DataAccessor = new DataAccessorInMemory(); ContactPersonTestBO boInvalid = ContactPersonTestBO.CreateUnsavedContactPerson("", ""); IBOPanelEditorControl controlWin = CreateEditorControl(boInvalid.ClassDef); controlWin.BusinessObject = boInvalid; //---------------Assert Precondition---------------- Assert.IsFalse(boInvalid.Status.IsValid()); AssertErrorProviderHasErrors(controlWin, "Surname"); //---------------Execute Test ---------------------- controlWin.BusinessObject = ContactPersonTestBO.CreateSavedContactPerson(); //---------------Test Result ----------------------- Assert.IsTrue(controlWin.BusinessObject.Status.IsValid()); AssertErrorProvidersHaveBeenCleared(controlWin); }