示例#1
0
        public void A_Criteria_Analyze_Result_Should_Be_Negated_If_Defined()
        {
            var childA = MockRepository.GenerateMock<CriteriaBase>();
            childA.Expect(x => x.Analyze(null)).Return(ResultEnumeration.@true);

            var target = new Modulo.Collect.OVAL.Results.CriteriaType() { @operator = OperatorEnumeration.AND };
            target.negate = true;
            target.Items = new List<object> { childA };

            var result = target.Analyze(null);

            Assert.AreEqual(ResultEnumeration.@false, result);
        }
示例#2
0
        public void A_Criteria_Analyze_Result_Should_Be_The_Combination_Of_All_Children_Criteria_Results()
        {
            var childA = MockRepository.GenerateMock<CriteriaBase>();
            childA.Expect(x => x.Analyze(null)).Return(ResultEnumeration.@true);
            var childB = MockRepository.GenerateMock<CriteriaBase>();
            childB.Expect(x => x.Analyze(null)).Return(ResultEnumeration.@false);

            var target = new Modulo.Collect.OVAL.Results.CriteriaType();
            target.@operator = OperatorEnumeration.AND;
            target.Items = new List<object> { childA, childB };

            var result = target.Analyze(null);

            Assert.AreEqual(ResultEnumeration.@false, result);
        }
示例#3
0
        public void A_Criteria_Analyze_Should_Evaluate_Result_Only_Once()
        {
            var childA = MockRepository.GenerateMock<CriteriaBase>();
            var defaultResult = default(ResultEnumeration);
            childA.Expect(x => x.Analyze(null)).Return(oval_results.NegateResult(defaultResult, true));
            var target = new Modulo.Collect.OVAL.Results.CriteriaType();
            target.@operator = OperatorEnumeration.AND;
            target.Items = new List<object> { childA };

            // First Call - should Evaluate Children
            var result = target.Analyze(null);
            // Second Call - Should Return Stored Result 
            result = target.Analyze(null);

            Assert.AreNotEqual(defaultResult, result);
        }
示例#4
0
        public void A_Criteria_Analyze_Result_Should_Be_The_Combination_Of_All_Children_Criteria_Results()
        {
            var childA = MockRepository.GenerateMock <CriteriaBase>();

            childA.Expect(x => x.Analyze(null)).Return(ResultEnumeration.@true);
            var childB = MockRepository.GenerateMock <CriteriaBase>();

            childB.Expect(x => x.Analyze(null)).Return(ResultEnumeration.@false);

            var target = new Modulo.Collect.OVAL.Results.CriteriaType();

            target.@operator = OperatorEnumeration.AND;
            target.Items     = new List <object> {
                childA, childB
            };

            var result = target.Analyze(null);

            Assert.AreEqual(ResultEnumeration.@false, result);
        }
示例#5
0
        public void A_Criteria_Analyze_Result_Should_Be_Negated_If_Defined()
        {
            var childA = MockRepository.GenerateMock <CriteriaBase>();

            childA.Expect(x => x.Analyze(null)).Return(ResultEnumeration.@true);

            var target = new Modulo.Collect.OVAL.Results.CriteriaType()
            {
                @operator = OperatorEnumeration.AND
            };

            target.negate = true;
            target.Items  = new List <object> {
                childA
            };

            var result = target.Analyze(null);

            Assert.AreEqual(ResultEnumeration.@false, result);
        }
示例#6
0
        public void A_Criteria_Analyze_Should_Evaluate_Result_Only_Once()
        {
            var childA        = MockRepository.GenerateMock <CriteriaBase>();
            var defaultResult = default(ResultEnumeration);

            childA.Expect(x => x.Analyze(null)).Return(oval_results.NegateResult(defaultResult, true));
            var target = new Modulo.Collect.OVAL.Results.CriteriaType();

            target.@operator = OperatorEnumeration.AND;
            target.Items     = new List <object> {
                childA
            };

            // First Call - should Evaluate Children
            var result = target.Analyze(null);

            // Second Call - Should Return Stored Result
            result = target.Analyze(null);

            Assert.AreNotEqual(defaultResult, result);
        }