コード例 #1
0
        public void Should_be_possible_to_get_value_of_an_external_variable()
        {
            var externalVariable = this.CreateExternalVariable("oval:modulo:var:4000", SimpleDatatypeEnumeration.@string);
            var ovalVariables = this.CreateOvalVariables(externalVariable.id, externalVariable.datatype,  new string[] { "answer" });
            var externalVariableEvaluator = new ExternalVariableEvaluator(externalVariable, ovalVariables);

            IEnumerable<string> variableEvaluationResult = externalVariableEvaluator.GetValue();

            Assert.IsTrue(variableEvaluationResult.Count() > 0, "the quantity of values is not expected.");
            Assert.AreEqual("answer", variableEvaluationResult.ElementAt(0), "A variable with an unexpected value was found.");
        }
コード例 #2
0
        public void When_the_external_variable_was_not_set_the_variable_evaluation_must_be_return_the_default_value_for_each_datatype()
        {
            var strExternalVar = this.CreateExternalVariable("oval:mss:var:1", SimpleDatatypeEnumeration.@string);
            var intExternalVar = this.CreateExternalVariable("oval:mss:var:2", SimpleDatatypeEnumeration.@int);
            var boolExternalVar = this.CreateExternalVariable("oval:mss:var:3", SimpleDatatypeEnumeration.boolean);
            var allExternalVariables = new Definitions.VariablesTypeVariableExternal_variable[] { strExternalVar, intExternalVar, boolExternalVar };
            var ovalVariables = this.CreateOvalVariablesFromExternalVariables(allExternalVariables);

            var stringExternalVarEvaluation = new ExternalVariableEvaluator(strExternalVar, ovalVariables).GetValue().Single();
            var integerExternalVarEvaluation = new ExternalVariableEvaluator(intExternalVar, ovalVariables).GetValue().Single();
            var booleanExternalVarEvaluation = new ExternalVariableEvaluator(boolExternalVar, ovalVariables).GetValue().Single();

            Assert.AreEqual(string.Empty, stringExternalVarEvaluation, "An unexpected default value for external string variable evaluation was found.");
            Assert.AreEqual(string.Empty, integerExternalVarEvaluation, "An unexpected default value for external integer variable evaluation was found.");
            Assert.AreEqual(string.Empty, booleanExternalVarEvaluation, "An unexpected default value for external boolean variable evaluation was found.");
        }