/// <summary> /// Throws an exception if the specified attribute is inherited, and therefor read-only /// </summary> /// <param name="attribute">The attribute to examine</param> protected void ThrowOnInheritedValueModification(AcmaSchemaAttribute attribute) { if (this.IsAttributeInherited(attribute)) { throw new InheritedValueModificationException(attribute.Name); } }
protected override void ValidatePropertyChange(string propertyName) { base.ValidatePropertyChange(propertyName); if (propertyName == "Attribute") { if (this.Attribute == null) { this.AddError("Attribute", "Attribute cannot be blank"); } else { NewAttributeChangeViewModel.lastSelectedAttribute = this.Attribute; this.RemoveError("Attribute"); } } else if (propertyName == "ModificationType") { if (this.AllowedModificationTypes.Contains(this.ModificationType)) { this.RemoveError("ModificationType"); } else { this.AddError("ModificationType", "Invalid modification type"); } } }
/// <summary> /// Gets a DBAttributeValues for the specified attribute of an MAObject /// </summary> /// <param name="attribute">The schema attribute to obtain</param> /// <param name="objectId">The ID of the MAObject to obtain the attributes from</param> /// <param name="context">The current data context used on this thread</param> /// <param name="adapter">The DataAdapter created for the DataTable returned by the method</param> /// <returns>A data table containing the result set</returns> private static DataTable GetAttributeValuesDataTable(AcmaSchemaAttribute attribute, Guid objectId, out SqlDataAdapter adapter) { using (SqlConnection connection = ActiveConfig.DB.GetNewConnection()) { SqlCommand command = new SqlCommand(); command.Connection = connection; command.CommandType = CommandType.Text; command.CommandText = string.Format("SELECT t1.[ID], t1.[objectId], t1.[attributeName], t1.[{1}] FROM [dbo].[{0}] t1 WHERE t1.[objectId]=@objectId AND t1.[attributeName]=@attributeName", attribute.TableName, attribute.ColumnName); command.Parameters.AddWithValue("@objectid", objectId); command.Parameters.AddWithValue("@attributeName", attribute.Name); adapter = new SqlDataAdapter(command); SqlCommandBuilder builder = new SqlCommandBuilder(adapter); builder.ConflictOption = ConflictOption.OverwriteChanges; builder.QuotePrefix = "["; builder.QuoteSuffix = "]"; DataSet dataset = new DataSet(); dataset.Locale = System.Globalization.CultureInfo.CurrentCulture; adapter.AcceptChangesDuringUpdate = true; adapter.Fill(dataset); if (dataset.Tables.Count == 0) { throw new DataException("The dataset contained no results"); } else { return(dataset.Tables[0]); } } }
protected override void ProcessRecord() { Global.ThrowIfNotConnected(this); try { AcmaSchemaObjectClass shadowClass = ActiveConfig.DB.GetObjectClass(this.ShadowObjectClass); if (!shadowClass.IsShadowObject) { throw new ArgumentException("The specified object class is not a shadow object class"); } AcmaSchemaObjectClass parentClass = shadowClass.ShadowFromObjectClass; AcmaSchemaAttribute provisioningAttribute = ActiveConfig.DB.GetAttribute(this.ProvisioningAttribute, parentClass); AcmaSchemaAttribute referenceAttribute = ActiveConfig.DB.GetAttribute(this.ReferenceAttribute, parentClass); ActiveConfig.DB.CreateShadowLink(shadowClass, provisioningAttribute, referenceAttribute, this.Name); // ActiveConfig.DB.ClearCache(); } catch (Exception ex) { ErrorRecord error = new ErrorRecord(ex, "UnknownError", ErrorCategory.NotSpecified, null); ThrowTerminatingError(error); } }
public void ExpandSimpleAttributeSVLong() { AcmaSchemaAttribute attribute = ActiveConfig.DB.GetAttribute("unixGid"); string declarationString = "{unixGid}"; AttributeDeclarationParser p = new AttributeDeclarationParser(declarationString); AttributeDeclaration target = p.GetAttributeDeclaration(); CSEntryChange sourceObject = CSEntryChange.Create(); sourceObject.ObjectModificationType = ObjectModificationType.Add; sourceObject.AttributeChanges.Add(AttributeChange.CreateAttributeAdd(attribute.Name, 99L)); object value = target.Expand(sourceObject).First(); if (value == null) { Assert.Fail("The declaration string did not return a value"); } else if (!(value is long)) { Assert.Fail("The declaration string returned the wrong data type"); } else if ((long)value != 99L) { Assert.Fail("The declaration string did not return the expected value"); } }
/// <summary> /// Initializes a new instance of the DBQueryByValue class /// </summary> /// <param name="searchAttribute">The attribute to search on</param> /// <param name="valueOperator">The comparison operator to use when searching values</param> public DBQueryByValue(AcmaSchemaAttribute searchAttribute, ValueOperator valueOperator) : this() { this.Initialize(); this.Operator = valueOperator; this.SearchAttribute = searchAttribute; }
public void ExpandSimpleAttributeMVStringWithTransforms() { AcmaSchemaAttribute attribute = ActiveConfig.DB.GetAttribute("mailAlternateAddresses"); AcmaSchemaObjectClass schemaObject = ActiveConfig.DB.GetObjectClass("person"); string declarationString = "{mailAlternateAddresses>>ToUpperCase}"; AttributeDeclarationParser p = new AttributeDeclarationParser(declarationString); AttributeDeclaration target = p.GetAttributeDeclaration(); CSEntryChange sourceObject = CSEntryChange.Create(); sourceObject.ObjectModificationType = ObjectModificationType.Add; sourceObject.AttributeChanges.Add(AttributeChange.CreateAttributeAdd(attribute.Name, new List <object>() { "*****@*****.**", "*****@*****.**", "*****@*****.**" })); object value = target.Expand(sourceObject); if (value == null) { Assert.Fail("The declaration string did not return a value"); } else if (!(value is IList <object>)) { Assert.Fail("The declaration string returned the wrong data type"); } else if (!((IList <object>)value).SequenceEqual(new List <object>() { "*****@*****.**", "*****@*****.**", "*****@*****.**" })) { Assert.Fail("The declaration string did not return the expected value"); } }
private static void HasValueTest(AcmaSchemaAttribute attribute, IList <object> values, object matchValue, object noMatchValue) { AttributeValues target = new InternalAttributeValues(attribute, values); Assert.AreEqual(true, target.HasValue(matchValue)); Assert.AreEqual(false, target.HasValue(noMatchValue)); }
private static void SequenceEqualsTest(AcmaSchemaAttribute attribute, IList <object> values, IList <object> matchingValues, IList <object> nonMatchingValues) { AttributeValues target = new InternalAttributeValues(attribute, values); Assert.AreEqual(true, target.SequenceEquals(matchingValues)); Assert.AreEqual(false, target.SequenceEquals(nonMatchingValues)); }
public void ExpandSimpleAttributeMVReference() { AcmaSchemaAttribute attribute = ActiveConfig.DB.GetAttribute("directReports"); AcmaSchemaObjectClass schemaObject = ActiveConfig.DB.GetObjectClass("person"); string declarationString = "{directReports}"; AttributeDeclarationParser p = new AttributeDeclarationParser(declarationString); AttributeDeclaration target = p.GetAttributeDeclaration(); CSEntryChange sourceObject = CSEntryChange.Create(); sourceObject.ObjectModificationType = ObjectModificationType.Add; sourceObject.AttributeChanges.Add(AttributeChange.CreateAttributeAdd(attribute.Name, new List <object>() { new Guid("fb116a90-35e3-47e9-92b7-679c4821e648"), new Guid("352285df-3fdc-468e-9412-70d62a62cefe"), new Guid("50ac8dbb-15fe-485c-8f02-87a77ab68a7b") })); object value = target.Expand(sourceObject); if (value == null) { Assert.Fail("The declaration string did not return a value"); } else if (!(value is IList <object>)) { Assert.Fail("The declaration string returned the wrong data type"); } else if (!((IList <object>)value).SequenceEqual(new List <object>() { new Guid("fb116a90-35e3-47e9-92b7-679c4821e648"), new Guid("352285df-3fdc-468e-9412-70d62a62cefe"), new Guid("50ac8dbb-15fe-485c-8f02-87a77ab68a7b") })) { Assert.Fail("The declaration string did not return the expected value"); } }
public void ExpandSimpleAttributeSVLongWithTransforms() { AcmaSchemaAttribute attribute = ActiveConfig.DB.GetAttribute("sapExpiryDate"); AcmaSchemaObjectClass schemaObject = ActiveConfig.DB.GetObjectClass("person"); string declarationString = "{sapExpiryDate>>Add30Days}"; AttributeDeclarationParser p = new AttributeDeclarationParser(declarationString); AttributeDeclaration target = p.GetAttributeDeclaration(); CSEntryChange sourceObject = CSEntryChange.Create(); sourceObject.ObjectModificationType = ObjectModificationType.Add; sourceObject.AttributeChanges.Add(AttributeChange.CreateAttributeAdd(attribute.Name, 1L)); object value = target.Expand(sourceObject).First(); if (value == null) { Assert.Fail("The declaration string did not return a value"); } else if (!(value is long)) { Assert.Fail("The declaration string returned the wrong data type"); } else if ((long)value != 25920000000001L) { Assert.Fail("The declaration string did not return the expected value"); } }
public void ExpandSimpleAttributeSVStringWithTransforms() { AcmaSchemaAttribute attribute = ActiveConfig.DB.GetAttribute("mail"); AcmaSchemaObjectClass schemaObject = ActiveConfig.DB.GetObjectClass("person"); string declarationString = "{mail>>ToUpperCase}"; AttributeDeclarationParser p = new AttributeDeclarationParser(declarationString); AttributeDeclaration target = p.GetAttributeDeclaration(); CSEntryChange sourceObject = CSEntryChange.Create(); sourceObject.ObjectModificationType = ObjectModificationType.Add; sourceObject.AttributeChanges.Add(AttributeChange.CreateAttributeAdd(attribute.Name, "*****@*****.**")); object value = target.Expand(sourceObject).First(); if (value == null) { Assert.Fail("The declaration string did not return a value"); } else if (!(value is string)) { Assert.Fail("The declaration string returned the wrong data type"); } else if ((string)value != "*****@*****.**") { Assert.Fail("The declaration string did not return the expected value"); } }
public void ExpandSimpleAttributeSVReference() { AcmaSchemaAttribute attribute = ActiveConfig.DB.GetAttribute("supervisor"); AcmaSchemaObjectClass schemaObject = ActiveConfig.DB.GetObjectClass("person"); string declarationString = "{supervisor}"; AttributeDeclarationParser p = new AttributeDeclarationParser(declarationString); AttributeDeclaration target = p.GetAttributeDeclaration(); CSEntryChange sourceObject = CSEntryChange.Create(); sourceObject.ObjectModificationType = ObjectModificationType.Add; sourceObject.AttributeChanges.Add(AttributeChange.CreateAttributeAdd(attribute.Name, new Guid("8c3cbf4e-5216-4a04-9140-b0b11020fa4c"))); object value = target.Expand(sourceObject).First(); if (value == null) { Assert.Fail("The declaration string did not return a value"); } else if (!(value is Guid)) { Assert.Fail("The declaration string returned the wrong data type"); } else if ((Guid)value != new Guid("8c3cbf4e-5216-4a04-9140-b0b11020fa4c")) { Assert.Fail("The declaration string did not return the expected value"); } }
/// <summary> /// Create a sub-select statement for a query condition where the operator specifies that the specified multivalued attribute value must not exist /// </summary> /// <param name="builder">The builder for this query</param> /// <param name="parameterNames">The parameters to evaluate against</param> /// <returns>An SQL SELECT statement</returns> private string CreateSubSelectStatementForMVNotEquals(DBQueryBuilder builder, IList <string> parameterNames) { string paramNameAttribute = builder.AddParameter(this.SearchAttribute.Name); WhereClause subClause = new WhereClause(WhereClauseRelationship.Or); WhereClause existWhere = new WhereClause(WhereClauseRelationship.And); AcmaSchemaAttribute objectIdAttribute = ActiveConfig.DB.GetAttribute("objectId"); existWhere.Terms.Add(WhereTerm.CreateCompare(SqlExpression.Field("objectId", this.SearchAttribute.DBTable), SqlExpression.Field(objectIdAttribute.Name, objectIdAttribute.DBTable), Reeb.SqlOM.CompareOperator.Equal)); existWhere.Terms.Add(WhereTerm.CreateCompare(SqlExpression.Field("attributeName", this.SearchAttribute.DBTable), SqlExpression.Parameter(paramNameAttribute), Reeb.SqlOM.CompareOperator.Equal)); foreach (string paramNameValue in parameterNames) { subClause.Terms.Add(WhereTerm.CreateCompare(SqlExpression.Field(this.SearchAttribute.ColumnName, this.SearchAttribute.DBTable), SqlExpression.Parameter(paramNameValue), Reeb.SqlOM.CompareOperator.Equal)); } existWhere.SubClauses.Add(subClause); SelectQuery subQuery = new SelectQuery(); subQuery.Columns.Add(new SelectColumn("objectId")); subQuery.Top = 1; subQuery.FromClause.BaseTable = this.SearchAttribute.DBTable; subQuery.WherePhrase.SubClauses.Add(existWhere); Reeb.SqlOM.Render.SqlServerRenderer render = new Reeb.SqlOM.Render.SqlServerRenderer(); string sql = render.RenderSelect(subQuery); return(sql); }
private static void EqualsObjectTest(AcmaSchemaAttribute attribute, object value, object matchingValue, object nonMatchingValue) { AttributeValue target = new AttributeValue(attribute, value); Assert.AreEqual(true, target.Equals(matchingValue)); Assert.AreEqual(false, target.Equals(nonMatchingValue)); }
public void ExpandSimpleAttributeMVLongWithTransforms() { AcmaSchemaAttribute attribute = ActiveConfig.DB.GetAttribute("expiryDates"); AcmaSchemaObjectClass schemaObject = ActiveConfig.DB.GetObjectClass("person"); string declarationString = "{expiryDates>>Add30Days}"; AttributeDeclarationParser p = new AttributeDeclarationParser(declarationString); AttributeDeclaration target = p.GetAttributeDeclaration(); CSEntryChange sourceObject = CSEntryChange.Create(); sourceObject.ObjectModificationType = ObjectModificationType.Add; sourceObject.AttributeChanges.Add(AttributeChange.CreateAttributeAdd(attribute.Name, new List <object>() { 1L, 2L, 3L, 4L })); object value = target.Expand(sourceObject); if (value == null) { Assert.Fail("The declaration string did not return a value"); } else if (!(value is IList <object>)) { Assert.Fail("The declaration string returned the wrong data type"); } else if (!((IList <object>)value).SequenceEqual(new List <object>() { 25920000000001L, 25920000000002L, 25920000000003L, 25920000000004L })) { Assert.Fail("The declaration string did not return the expected value"); } }
private static void TestAttributeChangeResults(CSEntryChange csentry, AcmaSchemaAttribute testAttribute, AttributeModificationType expectedModificationType, IList <object> expectedValues) { AttributeChange attributeChange = null; if (csentry.AttributeChanges.Contains(testAttribute.Name)) { attributeChange = csentry.AttributeChanges[testAttribute.Name]; } if (attributeChange == null && expectedModificationType == AttributeModificationType.Unconfigured) { return; } else if (attributeChange == null && expectedModificationType != AttributeModificationType.Unconfigured) { Assert.Fail("An AttributeChange was found where none were expected"); } else if (attributeChange == null) { Assert.Fail("An AttributeChange was expected but not found"); } if (attributeChange.ModificationType != expectedModificationType) { Assert.Fail("The AttributeChange was not of the expected type"); } if (expectedModificationType != AttributeModificationType.Delete) { List <AttributeValue> comparerValues1 = attributeChange.ValueChanges.Select(t => new AttributeValue(testAttribute, t.Value)).ToList(); List <AttributeValue> comparerValues2 = expectedValues.Select(t => new AttributeValue(testAttribute, t)).ToList(); CollectionAssert.AreEquivalent(comparerValues1, comparerValues2); } }
public void ExpandSimpleAttributeSVBoolean() { AcmaSchemaAttribute attribute = ActiveConfig.DB.GetAttribute("connectedToCallista"); AcmaSchemaObjectClass schemaObject = ActiveConfig.DB.GetObjectClass("person"); string declarationString = "{connectedToCallista}"; AttributeDeclarationParser p = new AttributeDeclarationParser(declarationString); AttributeDeclaration target = p.GetAttributeDeclaration(); CSEntryChange sourceObject = CSEntryChange.Create(); sourceObject.ObjectModificationType = ObjectModificationType.Add; sourceObject.AttributeChanges.Add(AttributeChange.CreateAttributeAdd(attribute.Name, true)); object value = target.Expand(sourceObject).First(); if (value == null) { Assert.Fail("The declaration string did not return a value"); } else if (!(value is bool)) { Assert.Fail("The declaration string returned the wrong data type"); } else if ((bool)value != true) { Assert.Fail("The declaration string did not return the expected value"); } }
public void TestCSEntryChangeAttributeUpdateOnObjectDelete() { ObjectModificationType objectModificationType = ObjectModificationType.Delete; AcmaSchemaAttribute testAttribute = ActiveConfig.DB.GetAttribute("mailAlternateAddresses"); IList <object> startValues = new List <object>() { "*****@*****.**", "*****@*****.**" }; IList <ValueChange> startValueChanges = new List <ValueChange>(startValues.Select(t => ValueChange.CreateValueAdd(t))); IList <object> changedValues = new List <object>() { "*****@*****.**", "*****@*****.**" }; IList <object> expectedValues = new List <object>() { "*****@*****.**", "*****@*****.**" }; CSEntryChange csentry; // No pending AttributeChanges csentry = CreateNewCSEntry(objectModificationType); try { csentry.AttributeChanges.UpdateAttribute(objectModificationType, testAttribute, startValueChanges); Assert.Fail("The expected exception was not thrown"); } catch (DeletedObjectModificationException) { } }
public void TestCSEntryChangeSplitCSEntries() { List <CSEntryChange> incomingchanges = new List <CSEntryChange>(); ObjectModificationType objectModificationType = ObjectModificationType.Add; AcmaSchemaAttribute testAttribute1 = ActiveConfig.DB.GetAttribute("supervisor"); AcmaSchemaAttribute testAttribute2 = ActiveConfig.DB.GetAttribute("accountName"); CSEntryChange csentry; Guid reference = Guid.NewGuid(); csentry = CreateNewCSEntry(objectModificationType); csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd(testAttribute1.Name, reference)); csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd(testAttribute2.Name, "testuser")); incomingchanges.Add(csentry); CSEntryChange csentry2; csentry2 = CreateNewCSEntry(objectModificationType); csentry2.AttributeChanges.Add(AttributeChange.CreateAttributeAdd(testAttribute2.Name, "testuser")); incomingchanges.Add(csentry2); List <CSEntryChange> changes = CSEntryChangeExtensions.SplitReferenceUpdatesFromCSEntryChanges(incomingchanges).ToList(); if (changes.Count != 3) { Assert.Fail("The operation returned the incorrect number of changes"); } }
protected override void ProcessRecord() { Global.ThrowIfNotConnected(this); try { AcmaSchemaObjectClass objectClass = ActiveConfig.DB.GetObjectClass(this.ObjectClass); AcmaSchemaAttribute attribute = ActiveConfig.DB.GetAttribute(this.Attribute); if (this.InheritanceSourceAttribute == null) { ActiveConfig.DB.CreateMapping(objectClass, attribute, objectClass.MappingsBindingList); } else { AcmaSchemaAttribute inheritedAttribute = ActiveConfig.DB.GetAttribute(this.InheritanceSourceAttribute); AcmaSchemaObjectClass inheritanceSourceObjectClass = ActiveConfig.DB.GetObjectClass(this.InheritanceSourceClass); AcmaSchemaAttribute innheritanceReference = ActiveConfig.DB.GetAttribute(this.InheritanceSourceReference); ActiveConfig.DB.CreateMapping(objectClass, attribute, innheritanceReference, inheritanceSourceObjectClass, inheritedAttribute, objectClass.MappingsBindingList); } ActiveConfig.DB.ClearCache(); Console.WriteLine("Binding added"); } catch (Exception ex) { ErrorRecord error = new ErrorRecord(ex, "UnknownError", ErrorCategory.NotSpecified, null); ThrowTerminatingError(error); } }
protected override void ProcessRecord() { Global.ThrowIfNotConnected(this); try { if (string.IsNullOrEmpty(this.Name)) { foreach (AcmaSchemaAttribute attribute in ActiveConfig.DB.Attributes) { this.WriteObject(attribute); } } else { AcmaSchemaAttribute attribute = ActiveConfig.DB.GetAttribute(this.Name); this.WriteObject(attribute); } } catch (Exception ex) { ErrorRecord error = new ErrorRecord(ex, "UnknownError", ErrorCategory.NotSpecified, null); ThrowTerminatingError(error); } }
public void Open(string filename) { XmlConfigFile existingModel = this.Model; UnitTestFileViewModel existingUTModel = this.UnitTestFile; try { ActiveConfig.DB.CanCache = true; AcmaSchemaAttribute.MissingAttributeEvent += AcmaSchemaAttribute_MissingAttributeEvent; UINotifyPropertyChanges.BeginIgnoreAllChanges(); this.Model = ActiveConfig.LoadXml(filename); this.unitTestFile = TestEngine.UnitTestFile.LoadXml(this.FileName); this.ReloadRootNodes(); this.ResetChangeState(); } catch { this.Model = existingModel; this.UnitTestFile = existingUTModel; throw; } finally { UINotifyPropertyChanges.EndIgnoreAllChanges(); this.RaisePropertyChanged("DisplayName"); this.RaisePropertyChanged("ChildNodes"); AcmaSchemaAttribute.ClearLostFoundCache(); AcmaSchemaAttribute.MissingAttributeEvent -= AcmaSchemaAttribute_MissingAttributeEvent; ActiveConfig.DB.CanCache = false; } }
public void ExpandSimpleAttributeSVBinary() { AcmaSchemaAttribute attribute = ActiveConfig.DB.GetAttribute("objectSid"); AcmaSchemaObjectClass schemaObject = ActiveConfig.DB.GetObjectClass("person"); string declarationString = "{objectSid}"; AttributeDeclarationParser p = new AttributeDeclarationParser(declarationString); AttributeDeclaration target = p.GetAttributeDeclaration(); CSEntryChange sourceObject = CSEntryChange.Create(); sourceObject.ObjectModificationType = ObjectModificationType.Add; sourceObject.AttributeChanges.Add(AttributeChange.CreateAttributeAdd(attribute.Name, new byte[] { 0, 1, 2, 3, 4 })); object value = target.Expand(sourceObject).First(); if (value == null) { Assert.Fail("The declaration string did not return a value"); } else if (!(value is byte[])) { Assert.Fail("The declaration string returned the wrong data type"); } else if (!((byte[])value).SequenceEqual(new byte[] { 0, 1, 2, 3, 4 })) { Assert.Fail("The declaration string did not return the expected value"); } }
public void PerformBulkUniqueAllocationTest() { UniqueValueConstructor constructor = new UniqueValueConstructor(); AcmaSchemaAttribute attribute = ActiveConfig.DB.GetAttribute("accountName"); constructor.UniqueAllocationAttributes = new System.Collections.Generic.List <AcmaSchemaAttribute>() { attribute }; constructor.ValueDeclaration = new UniqueValueDeclaration("{sn}%n%"); constructor.Attribute = attribute; List <Guid> preCreatedIDs = new List <Guid>(); List <Guid> testIDs = new List <Guid>(); int prestage = 100; int testcount = 200; try { for (int i = 1; i <= prestage; i++) { Guid newId = Guid.NewGuid(); MAObjectHologram sourceObject = ActiveConfig.DB.CreateMAObject(newId, "person"); preCreatedIDs.Add(newId); sourceObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("sn"), "yzhu"); sourceObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("accountName"), string.Format("yzhu{0}", i)); sourceObject.CommitCSEntryChange(); } for (int i = 1; i <= testcount; i++) { Guid newId = Guid.NewGuid(); MAObjectHologram sourceObject = ActiveConfig.DB.CreateMAObject(newId, "person"); testIDs.Add(newId); sourceObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("sn"), "yzhu"); constructor.Execute(sourceObject); sourceObject.CommitCSEntryChange(); AttributeValue value = sourceObject.GetSVAttributeValue(ActiveConfig.DB.GetAttribute("accountName")); Assert.AreEqual(string.Format("yzhu{0}", i + prestage), value.ValueString); } } finally { foreach (Guid id in preCreatedIDs) { ActiveConfig.DB.DeleteMAObjectPermanent(id); } foreach (Guid id in testIDs) { ActiveConfig.DB.DeleteMAObjectPermanent(id); } } }
public void ValueLongTest() { AcmaSchemaAttribute attribute = ActiveConfig.DB.GetAttribute("unixUid"); AttributeValue target = new AttributeValue(attribute, 1234L); Assert.AreEqual(true, target.ValueLong == 1234L); Assert.AreEqual(false, target.ValueLong == 4321L); }
public void ValueStringTest() { AcmaSchemaAttribute attribute = ActiveConfig.DB.GetAttribute("accountName"); AttributeValue target = new AttributeValue(attribute, "test"); Assert.AreEqual(true, target.ValueString == "test"); Assert.AreEqual(false, target.ValueString == "nottest"); }
/// <summary> /// Initializes a new instance of the DBQueryByValue class /// </summary> /// <param name="searchAttribute">The attribute to search for in the database</param> /// <param name="valueOperator">The operator to apply to values in the search</param> /// <param name="declarations">The value declarations to search for</param> public DBQueryByValue(AcmaSchemaAttribute searchAttribute, ValueOperator valueOperator, IList <ValueDeclaration> declarations) : this(searchAttribute, valueOperator) { foreach (var declaration in declarations) { this.ValueDeclarations.Add(declaration); } }
public void ValueGuidTest() { AcmaSchemaAttribute attribute = ActiveConfig.DB.GetAttribute("supervisor"); AttributeValue target = new AttributeValue(attribute, new Guid("1da92f76-e46f-42b0-a84d-a6a72be95ca6")); Assert.AreEqual(true, target.ValueGuid == new Guid("1da92f76-e46f-42b0-a84d-a6a72be95ca6")); Assert.AreEqual(false, target.ValueGuid == new Guid("11111f76-e46f-42b0-a84d-a6a72be95555")); }
public void ValueDateTimeTest() { AcmaSchemaAttribute attribute = ActiveConfig.DB.GetAttribute("dateTimeSV"); AttributeValue target = new AttributeValue(attribute, DateTime.Parse("2010-01-01")); Assert.AreEqual(true, target.ValueDateTime == DateTime.Parse("2010-01-01")); Assert.AreEqual(false, target.ValueDateTime == DateTime.Parse("2011-01-01")); }