public void ReferenceLookupUseAllResults() { ReferenceLookupConstructor constructor = new ReferenceLookupConstructor(); constructor.Attribute = ActiveConfig.DB.GetAttribute("displayNameSharers"); constructor.MultipleResultAction = MultipleResultAction.UseAll; constructor.QueryGroup = new DBQueryGroup() { Operator = GroupOperator.All }; constructor.QueryGroup.DBQueries.Add(new DBQueryByValue(ActiveConfig.DB.GetAttribute("displayName"), ValueOperator.Equals, ActiveConfig.DB.GetAttribute("displayName"))); Guid object1Id = Guid.NewGuid(); Guid object2Id = Guid.NewGuid(); Guid object3Id = Guid.NewGuid(); AcmaSchemaObjectClass objectClass = ActiveConfig.DB.GetObjectClass("person"); try { MAObjectHologram object1 = ActiveConfig.DB.CreateMAObject(object1Id, "person"); object1.SetAttributeValue(ActiveConfig.DB.GetAttribute("displayName"), "My Display Name"); object1.CommitCSEntryChange(); MAObjectHologram object2 = ActiveConfig.DB.CreateMAObject(object2Id, "person"); object2.SetAttributeValue(ActiveConfig.DB.GetAttribute("displayName"), "My Display Name"); object2.CommitCSEntryChange(); MAObjectHologram object3 = ActiveConfig.DB.CreateMAObject(object3Id, "person"); object3.SetAttributeValue(ActiveConfig.DB.GetAttribute("displayName"), "My Display Name"); constructor.Execute(object3); object3.CommitCSEntryChange(); object3 = ActiveConfig.DB.GetMAObject(object3Id, objectClass); AttributeValues values = object3.GetMVAttributeValues(ActiveConfig.DB.GetAttribute("displayNameSharers")); if (values.IsEmptyOrNull) { Assert.Fail("The constructor did not create any results"); } if (!values.ContainsAllElements(new List <object> { object1Id, object2Id })) { Assert.Fail("The constructor did not create the correct values"); } } finally { ActiveConfig.DB.DeleteMAObjectPermanent(object1Id); ActiveConfig.DB.DeleteMAObjectPermanent(object2Id); ActiveConfig.DB.DeleteMAObjectPermanent(object3Id); } }
public void ReferenceLookupErrorOnMultipleResults() { ReferenceLookupConstructor constructor = new ReferenceLookupConstructor(); constructor.Attribute = ActiveConfig.DB.GetAttribute("displayNameSharers"); constructor.MultipleResultAction = MultipleResultAction.Error; constructor.QueryGroup = new DBQueryGroup() { Operator = GroupOperator.All }; constructor.QueryGroup.DBQueries.Add(new DBQueryByValue(ActiveConfig.DB.GetAttribute("displayName"), ValueOperator.Equals, ActiveConfig.DB.GetAttribute("displayName"))); Guid object1Id = Guid.NewGuid(); Guid object2Id = Guid.NewGuid(); Guid object3Id = Guid.NewGuid(); try { MAObjectHologram object1 = ActiveConfig.DB.CreateMAObject(object1Id, "person"); object1.SetAttributeValue(ActiveConfig.DB.GetAttribute("displayName"), "My Display Name"); object1.CommitCSEntryChange(); MAObjectHologram object2 = ActiveConfig.DB.CreateMAObject(object2Id, "person"); object2.SetAttributeValue(ActiveConfig.DB.GetAttribute("displayName"), "My Display Name"); object2.CommitCSEntryChange(); try { MAObjectHologram object3 = ActiveConfig.DB.CreateMAObject(object3Id, "person"); object3.SetAttributeValue(ActiveConfig.DB.GetAttribute("displayName"), "My Display Name"); constructor.Execute(object3); object3.CommitCSEntryChange(); Assert.Fail("The expected exception was not throw"); } catch (MultipleMatchException) { } } finally { ActiveConfig.DB.DeleteMAObjectPermanent(object1Id); ActiveConfig.DB.DeleteMAObjectPermanent(object2Id); ActiveConfig.DB.DeleteMAObjectPermanent(object3Id); } }