Ejemplo n.º 1
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());
        }
        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();

        }
        public void Should_be_possible_to_build_a_system_characteristics_in_steps_and_generate_a_xml_from_this()
        {
            SystemCharacteristicsBuilder builder = new SystemCharacteristicsBuilder();

            oval_system_characteristics sc = this.GetSystemCharacteristics("oval.org.mitre.oval.sc.5368.xml");

            oval_system_characteristics systemCharacteristics = builder.WithGenerator(sc.generator)
                                                        .WithSystemInfo(sc.system_info)
                                                        .AddCollectedObjectsWithSystemData(sc.collected_objects, sc.system_data)
                                                        .Build();
            Assert.IsNotNull(systemCharacteristics);

            string systemCharacteristicsInXml = systemCharacteristics.GetSystemCharacteristicsXML();

            Assert.IsNotNull(systemCharacteristicsInXml);
        }
        public void Should_be_possible_to_build_a_new_system_characteristics_with_more_than_one_system_characteristics()
        {
            SystemCharacteristicsBuilder builder = new SystemCharacteristicsBuilder();

            oval_system_characteristics systemCharacteristics = this.GetSystemCharacteristics("oval.org.mitre.oval.sc.5368.xml");
            oval_system_characteristics ohterSystemCharacteristics = this.GetSystemCharacteristics("fdcc_xpfirewall_oval.sc.xml");

            oval_system_characteristics newSystemCharacteristics = builder.WithGenerator(systemCharacteristics.generator)
                                                                            .WithSystemInfo(systemCharacteristics.system_info)
                                                                            .AddCollectedObjectsWithSystemData(systemCharacteristics.collected_objects, systemCharacteristics.system_data)
                                                                            .AddCollectedObjectsWithSystemData(ohterSystemCharacteristics.collected_objects, ohterSystemCharacteristics.system_data)
                                                                            .Build();

            int expectedQuantity = systemCharacteristics.collected_objects.Count() + ohterSystemCharacteristics.collected_objects.Count();
            Assert.IsNotNull(newSystemCharacteristics);
            Assert.IsTrue(newSystemCharacteristics.collected_objects.Count() == expectedQuantity,"the quantity collectedObject is not expected");
            Assert.IsTrue(IsSequenceOfItemTypeExpected(newSystemCharacteristics), "the sequence is not expected.");
        }
        public void Should_be_possible_to_build_a_system_characteristics_in_steps()
        {
            SystemCharacteristicsBuilder builder = new SystemCharacteristicsBuilder();

            oval_system_characteristics sc = this.GetSystemCharacteristics("oval.org.mitre.oval.sc.5368.xml");

            oval_system_characteristics systemCharacteristics = builder.WithGenerator(sc.generator)
                                                        .WithSystemInfo(sc.system_info)
                                                        .AddCollectedObjectsWithSystemData(sc.collected_objects, sc.system_data)
                                                        .Build();

            Assert.IsNotNull(systemCharacteristics);
            Assert.IsTrue(systemCharacteristics.system_data.Count() == sc.system_data.Count(), "the system data is not expected");
            Assert.IsTrue(IsSequenceOfItemTypeExpected(systemCharacteristics), "the sequence in the system data is no expected");
        }