示例#1
0
        public static oval_definitions GetOvalDefinitionsFromStream(Stream definitionsDocument, out IEnumerable <string> schemaErrors)
        {
            var _schemaErrors = new List <string>();

            PrepareSerializer();

            XmlReaderSettings settings = new XmlReaderSettings();

            settings.ValidationType          = ValidationType.Schema;
            settings.XmlResolver             = xmlResolver;
            settings.ValidationFlags         = XmlSchemaValidationFlags.AllowXmlAttributes;
            settings.ValidationEventHandler += (o, args) => { if (args.Severity == XmlSeverityType.Error)
                                                              {
                                                                  _schemaErrors.Add(args.Message);
                                                              }
            };
            XmlReader        reader = XmlReader.Create(definitionsDocument, settings);
            oval_definitions result = xmlSerializer.Deserialize(reader) as oval_definitions;

            reader.Close();

            if (_schemaErrors.Count > 0)
            {
                result = null;
            }

            schemaErrors = _schemaErrors;
            return(result);
        }
        public void MyTestInitialize()
        {
            OvalDocumentLoader ovalDocument = new OvalDocumentLoader();

             this.OvalDefinitions = ovalDocument.GetFakeOvalDefinitions("definitionsWithLocalVariable.xml");
             this.OvalSystemCharacteristics = ovalDocument.GetFakeOvalSystemCharacteristics("system_characteristics_with_local_variable.xml");
        }
示例#3
0
 public static Definitions.ObjectType GetOvalComponentByOvalID(oval_definitions definitions, string ovalComponentID)
 {
     string ovalID = ovalComponentID.Contains(":") ? ovalComponentID : string.Format("oval:modulo:obj:{0}", ovalComponentID);
     return definitions.objects.Single(obj => obj.id.Equals(ovalID));
 }
 public ExternalVariableFactory(string definitionsResourceNameOnly)
 {
     this.OvalDefinitions = new OvalDocumentLoader().GetFakeOvalDefinitions(definitionsResourceNameOnly);
 }
示例#5
0
 public static string ExtractVariableValueFromConstantVariable(oval_definitions definitions, string variableID)
 {
     var variable = (VariablesTypeVariableConstant_variable)definitions.variables.Where(v => v.id.Equals(variableID)).First();
     return variable.value.First().Value;
 }
 private Definitions.ObjectType[] GetFakeObjectsFromDefinitions(oval_definitions definitions, string[] objectIDs)
 {
     var fakeObjects = new List<Definitions.ObjectType>();
     foreach(var objectID in objectIDs)
         fakeObjects.Add(ProbeHelper.GetOvalComponentByOvalID(definitions, string.Format("oval:modulo:obj:{0}", objectID)));
     
     return fakeObjects.ToArray();
 }
 public WmiItemTypeGeneratorTest()
 {
     this.OvalDefinitions = ProbeHelper.GetFakeOvalDefinitions("definitionsSimple.xml");
 }
 public FileEffectiveRights53EntityVariableEvaluatorTest()
 {
     this.Definitions = ProbeHelper.GetFakeOvalDefinitions("definitionsSimple");
 }
示例#9
0
 private string getConstantVariableValueFromOvalDefinitions(oval_definitions definitions, string variableID)
 {
     VariableType variable = definitions.variables.Where(var => var.id.Equals(variableID)).Single();
     return ((VariablesTypeVariableConstant_variable)variable).value.First().Value;
 }
示例#10
0
        private VariablesEvaluated createFakeVariablesEvaluated(oval_definitions definitions, string objectID, string variableID)
        {
            VariableType variable = definitions.variables.Where(var => var.id.Equals(variableID)).Single();
            string variableValue = ((VariablesTypeVariableConstant_variable)variable).value.First().Value;

            return VariableHelper.CreateVariableWithOneValue(objectID, variableID, variableValue);
        }
示例#11
0
 public FileObjectTests()
 {
     this.SimpleDefinitions = ProbeHelper.GetFakeOvalDefinitions("definitionsSimple.xml");
 }
 public void MyTestInitialize() 
 {
     definitions = ProbeHelper.GetFakeOvalDefinitions("definitionsWithConstantVariable.xml");
 }