Пример #1
0
        private string CreateOvalVariablesWithFakeValues()
        {
            var ovalDefinitions   = new OvalDocumentLoader().GetFakeOvalDefinitions(FDCC_XPFIREWALL);
            var externalVariables = ovalDefinitions.variables.OfType <VariablesTypeVariableExternal_variable>();

            var externalVariablesWithFakeValue = new oval_variables();

            foreach (var declaredExternalVariable in externalVariables)
            {
                var newFakeVariable = CreateVariableType(declaredExternalVariable);
                externalVariablesWithFakeValue.variables.Add(newFakeVariable);
            }

            return(externalVariablesWithFakeValue.GetXmlDocument());
        }
Пример #2
0
        public string GetEvaluatedExternalVariables(Dictionary <String, String> externalVariablesValues, IEnumerable <Definitions.VariablesTypeVariableExternal_variable> externalVariables)
        {
            var variables = new oval_variables
            {
                generator = Collect.OVAL.Common.DocumentHelpers.GetDefaultGenerator(),
                variables = new List <VariableType>()
            };

            foreach (var item in externalVariables)
            {
                string defaultValue = externalVariablesValues.Where(n => n.Key == item.id).Select(m => m.Value).SingleOrDefault() ?? String.Empty;
                variables.variables.Add(new VariableType(item.datatype, item.id, defaultValue));
            }

            return(variables.GetXmlDocument());
        }
Пример #3
0
        public void Test_Create_Variables_Document()
        {
            // Arrange / Act
            oval_variables variables = new oval_variables();

            variables.variables.Add(new VariableType(SimpleDatatypeEnumeration.@string, "oval:XX:var:1", "Red", "Green"));
            variables.variables.Add(new VariableType(SimpleDatatypeEnumeration.boolean, "oval:XX:var:2", "true"));

            //XmlSerializer xmlSerializer = new XmlSerializer(typeof(oval_variables));
            //StringBuilder sb = new StringBuilder();
            //StringWriter sw = new StringWriter(sb);
            //xmlSerializer.Serialize(sw, variables);

            IEnumerable <string> schemaErrors;
            oval_variables       result = oval_variables.GetOvalVariablesFromText(variables.GetXmlDocument(), out schemaErrors);

            // Assert
            Assert.AreEqual(0, schemaErrors.Count(), string.Join(Environment.NewLine, schemaErrors.ToArray()));
            Assert.IsNotNull(result);
            Assert.AreEqual(2, result.variables.Count);
        }