public void Should_be_access_variable_information_from_the_registry_object_by_the_registry_wrapper() { oval_definitions definitions = ProbeHelper.GetFakeOvalDefinitions("definitionsWithConstantVariable.xml"); registry_object ovalRegistryObject = (registry_object)ProbeHelper.GetOvalComponentByOvalID(definitions, "oval:org.mitre.oval:obj:3000"); Assert.IsNotNull(ovalRegistryObject, "the oval registry object is not exists in the fakeDefinitions"); RegistryObject registry = RegistryObjectFactory.CreateRegistryObject(ovalRegistryObject); Assert.AreEqual(registry.Hive, "HKEY_LOCAL_MACHINE", "the hive value is not expected"); Assert.AreEqual(registry.Key, "", "the key value is not expected"); Assert.AreEqual(registry.Name, "CurrentVersion", "the hive value is not expected"); Assert.AreEqual("oval:org.mitre.oval:var:3000", registry.GetVariableId(registry_object_ItemsChoices.key.ToString()), "the variableId from key is not expected"); Assert.AreEqual("", registry.GetVariableId(registry_object_ItemsChoices.name.ToString()), "the variableId from from name is not expected"); }
private IEnumerable<string> ProcessEntityVariables(RegistryObject registry,string entityName) { var values = new List<string>(); var variableId = registry.GetVariableId(entityName); var variableValues = variables.GetVariableValueForVariableId(variableId); if ((variableValues != null) && (variableValues.Count() > 0)) foreach (VariableValue variableValue in variableValues) values.AddRange(variableValue.values); else if ((registry.GetEntity(entityName) == null) || (string.IsNullOrEmpty(registry.GetEntity(entityName).var_ref))) values.Add(registry.GetValueOfEntity(entityName)); return values; }
private IEnumerable <string> ProcessEntityVariables(RegistryObject registry, string entityName) { var values = new List <string>(); var variableId = registry.GetVariableId(entityName); var variableValues = variables.GetVariableValueForVariableId(variableId); if ((variableValues != null) && (variableValues.Count() > 0)) { foreach (VariableValue variableValue in variableValues) { values.AddRange(variableValue.values); } } else if ((registry.GetEntity(entityName) == null) || (string.IsNullOrEmpty(registry.GetEntity(entityName).var_ref))) { values.Add(registry.GetValueOfEntity(entityName)); } return(values); }