コード例 #1
0
        public void EvaluateSVAVRBinaryEqualsTest()
        {
            bool expected = true;
            bool actual;
            Guid newId = Guid.NewGuid();

            try
            {
                MAObjectHologram maObject = ActiveConfig.DB.CreateMAObject(newId, "person");

                ValueComparisonRule target = new ValueComparisonRule();
                target.Attribute     = ActiveConfig.DB.GetAttribute("objectSid");
                target.ValueOperator = ValueOperator.Equals;
                target.ExpectedValue = new ValueDeclaration("AAECAwQ=");

                // Positive Tests
                maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("objectSid"), new byte[] { 0, 1, 2, 3, 4 });
                actual = target.Evaluate(maObject);
                Assert.AreEqual(expected, actual);

                // Negative Tests
                maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("objectSid"), new byte[] { 0, 0, 0, 3, 4 });
                actual = target.Evaluate(maObject);
                Assert.AreNotEqual(expected, actual);
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(newId);
            }
        }
コード例 #2
0
        public void EvaluateSVAVRStringEqualsProposedTest()
        {
            bool expected = true;
            bool actual;
            Guid newId = Guid.NewGuid();

            try
            {
                MAObjectHologram maObject = ActiveConfig.DB.CreateMAObject(newId, "person");

                ValueComparisonRule target = new ValueComparisonRule();
                target.Attribute     = ActiveConfig.DB.GetAttribute("mail");
                target.ValueOperator = ValueOperator.Equals;
                target.ExpectedValue = new ValueDeclaration("*****@*****.**");
                target.View          = HologramView.Proposed;

                // Positive Tests
                maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("mail"), "*****@*****.**");
                actual = target.Evaluate(maObject);
                Assert.AreEqual(expected, actual);

                // Negative Tests
                maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("mail"), "*****@*****.**");
                actual = target.Evaluate(maObject);
                Assert.AreNotEqual(expected, actual);
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(newId);
            }
        }
コード例 #3
0
        public void EvaluateSVAVRDateTimeEqualsTest()
        {
            bool expected = true;
            bool actual;

            Guid newId = Guid.NewGuid();

            try
            {
                MAObjectHologram maObject = ActiveConfig.DB.CreateMAObject(newId, "person");

                ValueComparisonRule target = new ValueComparisonRule();
                target.Attribute     = ActiveConfig.DB.GetAttribute("dateTimeSV");
                target.ValueOperator = ValueOperator.Equals;
                target.ExpectedValue = new ValueDeclaration("2010-01-01");

                // Positive Tests
                maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("dateTimeSV"), DateTime.Parse("2010-01-01"));
                actual = target.Evaluate(maObject);
                Assert.AreEqual(expected, actual);

                // Negative Tests
                maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("dateTimeSV"), DateTime.Parse("2011-01-01"));
                actual = target.Evaluate(maObject);
                Assert.AreNotEqual(expected, actual);
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(newId);
            }
        }
コード例 #4
0
        public void EvaluateSVAVRLongEqualsTest()
        {
            bool expected = true;
            bool actual;

            Guid newId = Guid.NewGuid();

            try
            {
                MAObjectHologram maObject = ActiveConfig.DB.CreateMAObject(newId, "person");

                ValueComparisonRule target = new ValueComparisonRule();
                target.Attribute     = ActiveConfig.DB.GetAttribute("sapExpiryDate");
                target.ValueOperator = ValueOperator.Equals;
                target.ExpectedValue = new ValueDeclaration("1234567890");

                // Positive Tests
                maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("sapExpiryDate"), 1234567890L);
                actual = target.Evaluate(maObject);
                Assert.AreEqual(expected, actual);

                // Negative Tests
                maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("sapExpiryDate"), 9876543210L);
                actual = target.Evaluate(maObject);
                Assert.AreNotEqual(expected, actual);
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(newId);
            }
        }
コード例 #5
0
        private static RuleGroup GetOneGroupTwoMatches()
        {
            ObjectClassScopeProviderForTest provider = new ObjectClassScopeProviderForTest("person");

            RuleGroup target = new RuleGroup();

            target.ObjectClassScopeProvider = provider;
            target.Operator = GroupOperator.One;
            ValueComparisonRule rule1 = new ValueComparisonRule();

            rule1.Attribute     = ActiveConfig.DB.GetAttribute("mail");
            rule1.ValueOperator = ValueOperator.Equals;
            rule1.ExpectedValue = new ValueDeclaration("*****@*****.**");
            target.Items.Add(rule1);

            ValueComparisonRule rule2 = new ValueComparisonRule();

            rule2.Attribute     = ActiveConfig.DB.GetAttribute("mail");
            rule2.ValueOperator = ValueOperator.Equals;
            rule2.ExpectedValue = new ValueDeclaration("*****@*****.**");
            target.Items.Add(rule2);

            ValueComparisonRule rule3 = new ValueComparisonRule();

            rule3.Attribute     = ActiveConfig.DB.GetAttribute("mail");
            rule3.ValueOperator = ValueOperator.Equals;
            rule3.ExpectedValue = new ValueDeclaration("*****@*****.**");
            target.Items.Add(rule3);

            return(target);
        }
コード例 #6
0
        public void EvaluateGroupAllTestNested()
        {
            Guid newId = Guid.NewGuid();

            try
            {
                MAObjectHologram maObject = ActiveConfig.DB.CreateMAObject(newId, "person");

                maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("mail"), "*****@*****.**");

                // Positive Tests
                RuleGroup target = GetAllGroup();
                RuleGroup group2 = GetAllGroup();
                target.Items.Add(group2);

                Assert.IsTrue(target.Evaluate(maObject));

                // Negative Tests
                ValueComparisonRule rule4 = new ValueComparisonRule();
                rule4.Attribute     = ActiveConfig.DB.GetAttribute("mail");
                rule4.ValueOperator = ValueOperator.Equals;
                rule4.ExpectedValue = new ValueDeclaration("*****@*****.**");
                target.Items.Add(rule4);

                Assert.IsFalse(target.Evaluate(maObject));
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(newId);
            }
        }
コード例 #7
0
        public ValueComparisonRuleViewModel(ValueComparisonRule model, bool canUseProposedValues)
            : base(model, canUseProposedValues)
        {
            this.typedModel = model;
            if (this.typedModel.ExpectedValue == null)
            {
                this.typedModel.ExpectedValue = new ValueDeclaration();
            }

            this.ExpectedValue = new ValueDeclarationViewModel(this.typedModel.ExpectedValue, this.typedModel.ObjectClass);
        }
コード例 #8
0
        public void EvaluateMVAVRNoMatchTest()
        {
            bool actual;
            bool expected = true;

            Guid newId = Guid.NewGuid();

            try
            {
                MAObjectHologram maObject = ActiveConfig.DB.CreateMAObject(newId, "person");

                ValueComparisonRule target = new ValueComparisonRule();
                target.Attribute     = ActiveConfig.DB.GetAttribute("mailAlternateAddresses");
                target.ValueOperator = ValueOperator.Equals;
                target.GroupOperator = GroupOperator.None;
                target.ExpectedValue = new ValueDeclaration("*****@*****.**");


                // Positive Tests
                maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("mailAlternateAddresses"), new List <object>()
                {
                    "*****@*****.**", "*****@*****.**", "*****@*****.**"
                });
                actual = target.Evaluate(maObject);
                Assert.AreEqual(expected, actual);

                maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("mailAlternateAddresses"), new List <object>()
                {
                    "*****@*****.**"
                });
                actual = target.Evaluate(maObject);
                Assert.AreEqual(expected, actual);

                // Negative Tests
                maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("mailAlternateAddresses"), new List <object>()
                {
                    "*****@*****.**", "*****@*****.**", "*****@*****.**"
                });
                actual = target.Evaluate(maObject);
                Assert.AreNotEqual(expected, actual);

                maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("mailAlternateAddresses"), new List <object>()
                {
                    "*****@*****.**"
                });
                actual = target.Evaluate(maObject);
                Assert.AreNotEqual(expected, actual);
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(newId);
            }
        }
コード例 #9
0
        public void TestSerialization()
        {
            ValueComparisonRule toSeralize = new ValueComparisonRule();

            toSeralize.Attribute     = ActiveConfig.DB.GetAttribute("firstName");
            toSeralize.ExpectedValue = new ValueDeclaration("test");
            toSeralize.ValueOperator = ValueOperator.Equals;
            toSeralize.View          = HologramView.Proposed;

            ValueComparisonRule deserialized = (ValueComparisonRule)UnitTestControl.XmlSerializeRoundTrip <ValueComparisonRule>(toSeralize);

            Assert.AreEqual(toSeralize.Attribute, deserialized.Attribute);
            Assert.AreEqual(toSeralize.ExpectedValue.Declaration, deserialized.ExpectedValue.Declaration);
            Assert.AreEqual(toSeralize.ExpectedValue.TransformsString, deserialized.ExpectedValue.TransformsString);
            Assert.AreEqual(toSeralize.ValueOperator, deserialized.ValueOperator);
            Assert.AreEqual(toSeralize.View, deserialized.View);
        }
コード例 #10
0
 public ValueComparisonRuleViewModel(ValueComparisonRule model)
     : base(model)
 {
     this.typedModel = model;
 }