public void EvaluateSVStringEqualsTest() { Guid newId = Guid.NewGuid(); try { MAObjectHologram maObject = ActiveConfig.DB.CreateMAObject(newId, "person"); AdvancedComparisonRule target = new AdvancedComparisonRule(); target.CompareAs = ExtendedAttributeType.String; target.SourceValue = new ValueDeclaration("test1"); target.TargetValue = new ValueDeclaration("test1"); target.ValueOperator = ValueOperator.Equals; target.GroupOperator = GroupOperator.Any; if (!target.Evaluate(maObject)) { Assert.Fail("The value comparison failed"); } target.TargetValue = new ValueDeclaration("test3"); if (target.Evaluate(maObject)) { Assert.Fail("The value comparison did not fail"); } } finally { ActiveConfig.DB.DeleteMAObjectPermanent(newId); } }
public void TestSerialization() { AdvancedComparisonRule toSeralize = new AdvancedComparisonRule(); toSeralize.CompareAs = ExtendedAttributeType.DateTime; toSeralize.SourceValue = new ValueDeclaration("test1"); toSeralize.TargetValue = new ValueDeclaration("test2"); toSeralize.ValueOperator = ValueOperator.NotContains; toSeralize.GroupOperator = GroupOperator.None; AdvancedComparisonRule deserialized = (AdvancedComparisonRule)UnitTestControl.XmlSerializeRoundTrip <AdvancedComparisonRule>(toSeralize); Assert.AreEqual(toSeralize.CompareAs, deserialized.CompareAs); Assert.AreEqual(toSeralize.SourceValue.Declaration, deserialized.SourceValue.Declaration); Assert.AreEqual(toSeralize.TargetValue.Declaration, deserialized.TargetValue.Declaration); Assert.AreEqual(toSeralize.ValueOperator, deserialized.ValueOperator); Assert.AreEqual(toSeralize.GroupOperator, deserialized.GroupOperator); }
public AdvancedComparisonRuleViewModel(AdvancedComparisonRule model, bool canUseProposedValues) : base(model, canUseProposedValues) { this.typedModel = model; if (this.typedModel.SourceValue == null) { this.typedModel.SourceValue = new ValueDeclaration(); } if (this.typedModel.TargetValue == null) { this.typedModel.TargetValue = new ValueDeclaration(); } this.SourceValue = new ValueDeclarationViewModel(this.typedModel.SourceValue, this.typedModel.ObjectClass); this.TargetValue = new ValueDeclarationViewModel(this.typedModel.TargetValue, this.typedModel.ObjectClass); }
public void EvaluateMVStringOneEqualsTest() { Guid newId = Guid.NewGuid(); try { MAObjectHologram maObject = ActiveConfig.DB.CreateMAObject(newId, "person"); maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("mailAlternateAddresses"), new List <object>() { "test1", "test2" }); maObject.CommitCSEntryChange(); AdvancedComparisonRule target = new AdvancedComparisonRule(); target.CompareAs = ExtendedAttributeType.String; target.SourceValue = new ValueDeclaration("{mailAlternateAddresses}"); target.TargetValue = new ValueDeclaration("test1"); target.ValueOperator = ValueOperator.Equals; target.GroupOperator = GroupOperator.One; if (!target.Evaluate(maObject)) { Assert.Fail("The value comparison failed"); } target.TargetValue = new ValueDeclaration("{mailAlternateAddresses}"); if (target.Evaluate(maObject)) { Assert.Fail("The value comparison did not fail"); } } finally { ActiveConfig.DB.DeleteMAObjectPermanent(newId); } }