示例#1
0
        public static oval_results CreateFromDocuments(
            Definitions.oval_definitions definitions,
            oval_system_characteristics systemcharacteristics,
            oval_variables evaluatedExternalVariables)
        {
            oval_results newResult = new oval_results();

            newResult.generator        = DocumentHelpers.GetDefaultGenerator();
            newResult.oval_definitions = definitions;
            newResult.results          = new List <SystemType> {
                new SystemType()
            };
            newResult.results[0].oval_system_characteristics = systemcharacteristics;
            newResult.EvaluatedExternalVariables             = evaluatedExternalVariables;

            // Generate new Definition Result entries
            foreach (var definition in definitions.definitions)
            {
                if ((definition.criteria == null) || (definition.criteria.Items == null) || (definition.criteria.Items.Count() < 1))
                {
                    continue;
                }
                var newDefinitionResult = new DefinitionType(definition);
                newResult.results[0].definitions.Add(newDefinitionResult);
            }
            // Generate new Test Result entries
            foreach (var test in definitions.tests)
            {
                var newTestResult = new TestType(test);
                newResult.results[0].tests.Add(newTestResult);
            }
            return(newResult);
        }
示例#2
0
 private oval_variables NewOvalVariables()
 {
     return(new oval_variables
     {
         generator = DocumentHelpers.GetDefaultGenerator(),
         variables = new List <OVAL.Variables.VariableType>()
     });
 }
示例#3
0
        public void Test_Generator_Is_Created()
        {
            // Arrange
            DateTime dtJustBefore = DateTime.Now; System.Threading.Thread.Sleep(100);

            // Act
            GeneratorType generator = DocumentHelpers.GetDefaultGenerator();

            // Pre-Assert Arrange
            System.Threading.Thread.Sleep(100); DateTime dtJustAfter = DateTime.Now;

            // Assert
            Assert.IsNotNull(generator);
            Assert.IsTrue((generator.timestamp > dtJustBefore) && (generator.timestamp < dtJustAfter));
            Assert.IsFalse(string.IsNullOrEmpty(generator.product_name));
            Assert.IsFalse(string.IsNullOrEmpty(generator.product_version));
            Assert.IsTrue(generator.schema_version >= (decimal)5.6);
        }
示例#4
0
        private oval_system_characteristics CreateSystemCharacteristicsBySpecificSystemInfo(IEnumerable <oval_system_characteristics> systemCharacteristics, SystemInfoType systemInfo)
        {
            SystemCharacteristicsBuilder builder = new SystemCharacteristicsBuilder();
            var generator = (systemCharacteristics.Count() > 0) ? systemCharacteristics.ElementAt(0).generator : DocumentHelpers.GetDefaultGenerator();

            return(builder.WithGenerator(generator)
                   .WithSystemInfo(systemInfo)
                   .WithCollectedObjectAndSystemDataByTheSystemCharacteristicList(systemCharacteristics)
                   .Build());
        }
示例#5
0
 /// <summary>
 /// Gets the generator. It is important for the header of the system characteristics.
 /// </summary>
 /// <returns></returns>
 private GeneratorType GetGenerator()
 {
     return(DocumentHelpers.GetDefaultGenerator());
 }