public void Should_be_possible_to_evaluate_a_constant_variables_of_an_entitytype() { oval_definitions definitions = new OvalDocumentLoader().GetFakeOvalDefinitions("oval_definitions.oval.org.mitre.oval.def.5921.xml"); Assert.IsNotNull(definitions, "the definitios is not created"); EntityObjectStringType entityType = new EntityObjectStringType(); entityType.var_ref = "oval:org.mitre.oval:var:932"; VariableEvaluator variableEvaluator = new VariableEvaluator(definitions.variables, null, null); IEnumerable <string> values = variableEvaluator.Evaluate(entityType); Assert.IsNotNull(values, "the valueToMatch of variable is null"); Assert.IsTrue(values.Count() == 1, "the quantity of values is not expected"); Assert.IsTrue(values.ElementAt(0) == "1", "the valueToMatch is not expected"); }
public void Should_not_evaluate_a_variable_if_the_entityType_not_have_a_variable_reference() { oval_definitions definitions = new OvalDocumentLoader().GetFakeOvalDefinitions("definitionsSimple.xml"); Assert.IsNotNull(definitions, "the definitios is not created"); registry_object registryObject = (registry_object)definitions.objects[1]; Dictionary <String, EntityObjectStringType> registryEntities = this.GetRegistryEntitiesFromName(registryObject); EntitySimpleBaseType keyName = registryEntities[registry_object_ItemsChoices.key.ToString()]; VariableEvaluator variableEvaluator = new VariableEvaluator(definitions.variables, null, null); IEnumerable <string> values = variableEvaluator.Evaluate(keyName); Assert.IsNotNull(values, "the valueToMatch of variable is null"); Assert.IsTrue(values.Count() == 1, "the quantity of values is not expected"); Assert.IsTrue(values.ElementAt(0) == @"Software\Microsoft\Windows NT\CurrentVersion", "the valueToMatch is not expected"); }
public void Should_be_evaluate_a_local_Variables_of_an_entityType() { OvalDocumentLoader ovalDocument = new OvalDocumentLoader(); oval_definitions definitions = ovalDocument.GetFakeOvalDefinitions("definitionsWithLocalVariable.xml"); Assert.IsNotNull(definitions, "the definitios is not created"); oval_system_characteristics systemCharacteristics = ovalDocument.GetFakeOvalSystemCharacteristics("system_characteristics_with_local_variable.xml"); Assert.IsNotNull(definitions, "the system Characteristics is not was created"); EntityObjectStringType entityType = new EntityObjectStringType(); entityType.var_ref = "oval:org.mitre.oval:var:4000"; VariableEvaluator variableEvaluator = new VariableEvaluator(definitions.variables, systemCharacteristics, null); IEnumerable <string> values = variableEvaluator.Evaluate(entityType); Assert.IsNotNull(values, "the valueToMatch of variable is null"); Assert.IsTrue(values.Count() == 1, "the quantity of values is not expected"); Assert.IsTrue(values.ElementAt(0) == @"Software\Microsoft\Windows NT\CurrentVersion", "the value is not expected"); }