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 AttributeDeleteConstructorMVTest() { AttributeValueDeleteConstructor attributeConstructor = new AttributeValueDeleteConstructor(); attributeConstructor.Attribute = ActiveConfig.DB.GetAttribute("mailAlternateAddresses"); attributeConstructor.RuleGroup = new RuleGroup(); attributeConstructor.RuleGroup.Items.Add(new ObjectChangeRule() { TriggerEvents = TriggerEvents.Add }); Guid newId = Guid.NewGuid(); try { MAObjectHologram sourceObject = ActiveConfig.DB.CreateMAObject(newId, "person"); sourceObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("mailAlternateAddresses"), new List <object>() { "*****@*****.**", "*****@*****.**", "*****@*****.**" }); sourceObject.CommitCSEntryChange(); sourceObject.DiscardPendingChanges(); sourceObject.SetObjectModificationType(ObjectModificationType.Update, false); attributeConstructor.Execute(sourceObject); AttributeValues values = sourceObject.GetMVAttributeValues(ActiveConfig.DB.GetAttribute("mailAlternateAddresses")); if (values.Values.Count != 0) { Assert.Fail("The constructor did not delete the attribute value"); } } finally { ActiveConfig.DB.DeleteMAObjectPermanent(newId); } }
public void ExportCSEntryChangeAdd() { Guid id = Guid.NewGuid(); CSEntryChange csentry = CSEntryChange.Create(); csentry.DN = id.ToString(); csentry.ObjectModificationType = ObjectModificationType.Add; csentry.ObjectType = "person"; csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("mail", "*****@*****.**")); csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("mailAlternateAddresses", new List <object> { "*****@*****.**", "*****@*****.**" })); csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("unixUid", 44L)); csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("expiryDates", new List <object>() { 55L, 66L, 77L })); csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("directReports", new List <object>() { new Guid("{8FC92471-7835-4804-8BBB-0A5ED7078074}"), new Guid("{0EF7CC21-729E-4ED9-A3AF-8203796334C6}") })); csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("supervisor", new Guid("{2807ED76-E262-4EB4-ABD9-9629F3830F12}"))); csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("connectedToSap", true)); csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("dateTimeMV", new List <object>() { DateTime.Parse("2010-01-01"), DateTime.Parse("2011-01-01") })); csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("dateTimeSV", DateTime.Parse("2012-01-01"))); csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("objectSids", new List <object>() { new byte[] { 0, 1, 2, 3, 4, 5 }, new byte[] { 2, 4, 6, 8, 0 } })); csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("objectSid", new byte[] { 0, 1, 2, 3, 4 })); AcmaSchemaObjectClass objectClass = ActiveConfig.DB.GetObjectClass("person"); try { bool refretry; CSEntryExport.PutExportEntry(csentry, out refretry); MAObjectHologram sourceObject = ActiveConfig.DB.GetMAObject(id, objectClass); if (sourceObject.GetSVAttributeValue(ActiveConfig.DB.GetAttribute("mail")).ValueString != "*****@*****.**") { Assert.Fail("One or more attribute changes were not committed"); } if (sourceObject.GetSVAttributeValue(ActiveConfig.DB.GetAttribute("dateTimeSV")).ValueDateTime != DateTime.Parse("2012-01-01")) { Assert.Fail("One or more attribute changes were not committed"); } if (sourceObject.GetSVAttributeValue(ActiveConfig.DB.GetAttribute("unixUid")).ValueLong != 44L) { Assert.Fail("One or more attribute changes were not committed"); } if (sourceObject.GetSVAttributeValue(ActiveConfig.DB.GetAttribute("connectedToSap")).ValueBoolean != true) { Assert.Fail("One or more attribute changes were not committed"); } if (!sourceObject.GetSVAttributeValue(ActiveConfig.DB.GetAttribute("objectSid")).ValueByte.SequenceEqual(new byte[] { 0, 1, 2, 3, 4 })) { Assert.Fail("One or more attribute changes were not committed"); } if (sourceObject.GetSVAttributeValue(ActiveConfig.DB.GetAttribute("supervisor")).ValueGuid != new Guid("{2807ED76-E262-4EB4-ABD9-9629F3830F12}")) { Assert.Fail("One or more attribute changes were not committed"); } if (!sourceObject.GetMVAttributeValues(ActiveConfig.DB.GetAttribute("mailAlternateAddresses")).ContainsAllElements(new List <object> { "*****@*****.**", "*****@*****.**" })) { Assert.Fail("One or more attribute changes were not committed"); } if (!sourceObject.GetMVAttributeValues(ActiveConfig.DB.GetAttribute("expiryDates")).ContainsAllElements(new List <object>() { 55L, 66L, 77L })) { Assert.Fail("One or more attribute changes were not committed"); } if (!sourceObject.GetMVAttributeValues(ActiveConfig.DB.GetAttribute("dateTimeMV")).ContainsAllElements(new List <object>() { DateTime.Parse("2010-01-01"), DateTime.Parse("2011-01-01") })) { Assert.Fail("One or more attribute changes were not committed"); } if (!sourceObject.GetMVAttributeValues(ActiveConfig.DB.GetAttribute("directReports")).ContainsAllElements(new List <object>() { new Guid("{8FC92471-7835-4804-8BBB-0A5ED7078074}"), new Guid("{0EF7CC21-729E-4ED9-A3AF-8203796334C6}") })) { Assert.Fail("One or more attribute changes were not committed"); } if (!sourceObject.GetMVAttributeValues(ActiveConfig.DB.GetAttribute("objectSids")).ContainsAllElements(new List <object>() { new byte[] { 0, 1, 2, 3, 4, 5 }, new byte[] { 2, 4, 6, 8, 0 } })) { Assert.Fail("One or more attribute changes were not committed"); } } finally { ActiveConfig.DB.DeleteMAObjectPermanent(id); } }