public void Should_be_possible_to_calculate_the_difference_between_dates_with_literal_Component_with_seconds_since_epoch()
        {
            VariablesTypeVariableLocal_variable localVariable =
                LocalVariableBuilder
                .CreateTheLocalVariable()
                .WithTimeDifference()
                .WithFirstFormat(DateTimeFormatEnumeration.year_month_day)
                .WithSecondFormat(DateTimeFormatEnumeration.seconds_since_epoch)
                .AddLiteralComponent("2009-09-03 17:43:12")
                .AddLiteralComponent("1251996192")
                .SetInLocalVariable()
                .Build();

            LocalVariableComponentsFactory factory   = new LocalVariableComponentsFactory(systemCharacteristics, definitions.variables);
            LocalVariableComponent         component = factory.GetLocalVariableComponent(localVariable);
            IEnumerable <string>           values    = component.GetValue();

            TimeDifferenceFormatter formatter = new TimeDifferenceFormatter();
            DateTime dateFromSeconds          = formatter.GetDateInFormat("1251996192", DateTimeFormatEnumeration.seconds_since_epoch);
            DateTime firstDate  = new DateTime(2009, 09, 03, 17, 43, 12);
            TimeSpan difference = dateFromSeconds - firstDate;


            Assert.IsTrue(values.Count() > 0, "the quantity is not expected");
            Assert.IsTrue(values.ElementAt(0) == difference.TotalSeconds.ToString()); // in seconds
        }
        public void Should_be_possible_to_get_value_of_concatFunction_with_ObjectComponent_and_LiteralComponent()
        {
            VariablesTypeVariableLocal_variable localVariable = LocalVariableBuilder.
                                                                CreateTheLocalVariable().
                                                                WithConcat().
                                                                AddLiteralComponent(@"c:\").
                                                                AddObjectComponent("oval:org.mitre.oval:obj:1000", "family").
                                                                SetInLocalVariable().
                                                                Build();

            oval_definitions definitions = this.ovalDocument.GetFakeOvalDefinitions("definitionsWithLocalVariable.xml");

            Assert.IsNotNull(definitions, "the definitions was loaded");

            oval_system_characteristics systemCharacteristics = this.ovalDocument.GetFakeOvalSystemCharacteristics("system_characteristics_with_local_variable.xml");

            Assert.IsNotNull(systemCharacteristics, "the systemCharacteristics was not loaded");

            LocalVariableComponentsFactory factory = new LocalVariableComponentsFactory(systemCharacteristics, definitions.variables);

            LocalVariableComponent concatFunctionComponent = factory.GetLocalVariableComponent(localVariable);

            Assert.IsInstanceOfType(concatFunctionComponent, typeof(ConcatFunctionComponent));
            IEnumerable <string> values = concatFunctionComponent.GetValue();

            Assert.IsTrue(values.Count() > 0, "the quantity is not expected");
            Assert.IsTrue(values.ElementAt(0) == @"c:\windows", "the value is not expected");
        }
        public void Should_be_possible_to_get_value_of_concatFunction_with_multiples_values_of_return()
        {
            VariablesTypeVariableLocal_variable localVariable = LocalVariableBuilder.
                                                                CreateTheLocalVariable().
                                                                WithConcat().
                                                                AddObjectComponent("oval:org.mitre.oval:obj:5000", "name").
                                                                AddLiteralComponent(@"\").
                                                                AddObjectComponent("oval:org.mitre.oval:obj:6000", "name").
                                                                AddLiteralComponent(@"\").
                                                                AddObjectComponent("oval:org.mitre.oval:obj:7000", "name").
                                                                SetInLocalVariable().
                                                                Build();

            oval_definitions definitions = this.ovalDocument.GetFakeOvalDefinitions("definitionsWithLocalVariable.xml");

            Assert.IsNotNull(definitions, "the definitions was loaded");

            oval_system_characteristics systemCharacteristics = this.ovalDocument.GetFakeOvalSystemCharacteristics("system_characteristics_with_local_variable.xml");

            Assert.IsNotNull(systemCharacteristics, "the systemCharacteristics was not loaded");

            LocalVariableComponentsFactory factory = new LocalVariableComponentsFactory(systemCharacteristics, definitions.variables);

            LocalVariableComponent concatFunctionComponent = factory.GetLocalVariableComponent(localVariable);

            Assert.IsInstanceOfType(concatFunctionComponent, typeof(ConcatFunctionComponent));
            IEnumerable <string> values = concatFunctionComponent.GetValue();

            Assert.IsTrue(values.Count() == 4, "the quantity is not expected");
            Assert.IsTrue(values.ElementAt(0) == @"BuildLabEx\SoftwareType\InstallDate", "the value is not expected");
            Assert.IsTrue(values.ElementAt(1) == @"BuildLabEx\SystemRoot\InstallDate", "the value is not expected");
            Assert.IsTrue(values.ElementAt(2) == @"CSDBuildNumber\SoftwareType\InstallDate", "the value is not expected");
            Assert.IsTrue(values.ElementAt(3) == @"CSDBuildNumber\SystemRoot\InstallDate", "the value is not expected");
        }
        public void Should_be_possible_to_calculate_the_difference_between_dates_with_objectComponent_with_multiples_values()
        {
            VariablesTypeVariableLocal_variable localVariable =
                LocalVariableBuilder
                .CreateTheLocalVariable()
                .WithTimeDifference()
                .WithFirstFormat(DateTimeFormatEnumeration.day_month_year)
                .WithSecondFormat(DateTimeFormatEnumeration.day_month_year)
                .AddObjectComponent("value", "oval:org.mitre.oval:obj:10001")
                .AddObjectComponent("value", "oval:org.mitre.oval:obj:10002")
                .SetInLocalVariable()
                .Build();

            LocalVariableComponentsFactory factory   = new LocalVariableComponentsFactory(systemCharacteristics, definitions.variables);
            LocalVariableComponent         component = factory.GetLocalVariableComponent(localVariable);
            IEnumerable <string>           values    = component.GetValue();

            DateTime firstDate    = new DateTime(2009, 10, 25, 0, 0, 0);
            DateTime secondDate   = new DateTime(2009, 11, 25, 0, 0, 0);
            TimeSpan firstElement = secondDate - firstDate;

            secondDate = new DateTime(2009, 12, 25, 0, 0, 0);
            TimeSpan secondElement = secondDate - firstDate;

            Assert.IsTrue(values.Count() > 0, "the quantity is not expected");
            Assert.AreEqual(values.ElementAt(0), firstElement.TotalSeconds.ToString(), "the difference is not expected");  // in seconds
            Assert.AreEqual(values.ElementAt(1), secondElement.TotalSeconds.ToString(), "the difference is not expected"); // in seconds
        }
        public void Should_throws_exception_when_the_value_type_is_not_correct_in_multiply_operation()
        {
            Assert.IsNotNull(definitions, "the definitions was loaded");
            Assert.IsNotNull(systemCharacteristics, "the systemCharacteristics was not loaded");

            VariablesTypeVariableLocal_variable localVariable = LocalVariableBuilder
                                                                .CreateTheLocalVariable()
                                                                .WithArithmetic()
                                                                .WithArithmeticOperation(ArithmeticEnumeration.multiply)
                                                                .AddLiteralComponent("A", SimpleDatatypeEnumeration.@string)
                                                                .AddLiteralComponent("B", SimpleDatatypeEnumeration.@string)
                                                                .SetInLocalVariable()
                                                                .Build();

            LocalVariableComponentsFactory factory   = new LocalVariableComponentsFactory(systemCharacteristics, definitions.variables);
            LocalVariableComponent         component = factory.GetLocalVariableComponent(localVariable);

            Assert.IsInstanceOfType(component, typeof(ArithmeticFunctionComponent));

            try
            {
                IEnumerable <string> values = component.GetValue();
            }
            catch (Exception exc)
            {
                Assert.IsInstanceOfType(exc, typeof(FormatException), "the exception is not corret in multiply operator");
            }
        }
Exemple #6
0
        private IEnumerable <string> EvaluateVariable(VariablesTypeVariableLocal_variable localVariable)
        {
            LocalVariableComponentsFactory factory = new LocalVariableComponentsFactory(OvalSystemCharacteristics, OvalDefinitions.variables);
            LocalVariableComponent         localVariableComponent = factory.GetLocalVariableComponent(localVariable);
            IEnumerable <string>           values = localVariableComponent.GetValue();

            return(values);
        }
Exemple #7
0
        public void Should_be_possible_to_instantiate_a_ConstantVariableComponent()
        {
            VariablesTypeVariableLocal_variable localVariable = new VariablesTypeVariableLocal_variable()
            {
                Item = new ObjectComponentType()
            };

            LocalVariableComponentsFactory factory           = new LocalVariableComponentsFactory(null, null);
            LocalVariableComponent         variableComponent = factory.GetLocalVariableComponent(localVariable);

            Assert.IsInstanceOfType(variableComponent, typeof(LocalVariableObjectComponent), "the variable component is not expected");
        }
Exemple #8
0
        private List <string> ExceuteRegexCaptureFunction()
        {
            List <string>          resultsOfExpression = new List <string>();
            string                 resultOfExpression  = "";
            LocalVariableComponent variable            = base.components.First();
            IEnumerable <string>   values = variable.GetValue();

            foreach (string value in values)
            {
                resultOfExpression = Regex.Match(value, component.pattern, RegexOptions.ExplicitCapture).ToString();
                resultsOfExpression.Add(resultOfExpression);
            }

            return(resultsOfExpression);
        }
Exemple #9
0
        /// <summary>
        /// Calculates the difference of values of first component with other compoenents.
        /// For each value of first component results, the difference is calculate with results of other components.
        /// </summary>
        /// <returns></returns>
        private IEnumerable <string> CalculateDifferenceOfValuesOfFirstComponentWithOtherCompoenents()
        {
            List <string> values = new List <string>();
            List <LocalVariableComponent> componentsClone        = this.CloneComponentList();
            LocalVariableComponent        firstComponent         = componentsClone.First();
            IEnumerable <string>          valuesOfFirstComponent = firstComponent.GetValue();

            componentsClone.Remove(firstComponent);

            foreach (string value in valuesOfFirstComponent)
            {
                values.AddRange(this.CalculateDifferenceWithOtherResults(value, componentsClone));
            }
            return(values);
        }
        private List <string> ExecuteSplitFunction()
        {
            List <string>          resultsOfExpression = new List <string>();
            LocalVariableComponent variable            = base.components.First();
            IEnumerable <string>   values = variable.GetValue();

            foreach (string value in values)
            {
                List <string> valuesOfResultFunction = new List <string>();
                string[]      resultOfExpression     = value.ToString().Split(component.delimiter.ToCharArray());
                resultsOfExpression.AddRange(resultOfExpression);
            }

            return(resultsOfExpression);
        }
Exemple #11
0
        private List <string> ExecuteEscapeRegexFunction()
        {
            List <string>          resultsOfExpression = new List <string>();
            string                 resultOfExpression  = "";
            LocalVariableComponent variable            = base.components.First();
            IEnumerable <string>   values = variable.GetValue();

            foreach (string value in values)
            {
                resultOfExpression = Regex.Escape(value).ToString();
                resultsOfExpression.Add(resultOfExpression);
            }

            return(resultsOfExpression);
        }
Exemple #12
0
        public void Should_be_possible_to_instantiate_a_FunctionComponent()
        {
            ConcatFunctionType concatFunction = new ConcatFunctionType()
            {
                Items = new object[] { new ObjectComponentType(), new LiteralComponentType() }
            };
            VariablesTypeVariableLocal_variable localVariable = new VariablesTypeVariableLocal_variable()
            {
                Item = concatFunction
            };

            LocalVariableComponentsFactory factory           = new LocalVariableComponentsFactory(null, null);
            LocalVariableComponent         variableComponent = factory.GetLocalVariableComponent(localVariable);

            Assert.IsInstanceOfType(variableComponent, typeof(LocalVariableFunctionComponent));
            Assert.IsTrue(((LocalVariableFunctionComponent)variableComponent).QuantityOfComponents() == 2, "the quantity of component is not expected");
        }
        public void Should_be_possible_to_apply_a_beginFunction_with_ObjectComponent_defined()
        {
            VariablesTypeVariableLocal_variable localVariable = LocalVariableBuilder
                                                                .CreateTheLocalVariable()
                                                                .WithBegin()
                                                                .WithCharacter(@"Software\")
                                                                .AddObjectComponent("oval:org.mitre.oval:obj:3000", "name")
                                                                .SetInLocalVariable()
                                                                .Build();

            LocalVariableComponentsFactory factory   = new LocalVariableComponentsFactory(systemCharacteristics, definitions.variables);
            LocalVariableComponent         component = factory.GetLocalVariableComponent(localVariable);

            IEnumerable <string> values = component.GetValue();

            Assert.IsTrue(values.Count() == 1, "the quantity of values is not expected");
            Assert.IsTrue(values.ElementAt(0) == @"Software\CurrentVersion", "the value is not expected");
        }
        public void Should_not_add_the_character_in_the_start_of_expression_if_the_expression_start_with_him()
        {
            VariablesTypeVariableLocal_variable localVariable = LocalVariableBuilder
                                                                .CreateTheLocalVariable()
                                                                .WithBegin()
                                                                .WithCharacter(@"\Software")
                                                                .AddLiteralComponent(@"\Software\Microsoft\Windows NT\CurrentVersion")
                                                                .SetInLocalVariable()
                                                                .Build();

            LocalVariableComponentsFactory factory   = new LocalVariableComponentsFactory(systemCharacteristics, definitions.variables);
            LocalVariableComponent         component = factory.GetLocalVariableComponent(localVariable);

            IEnumerable <string> values = component.GetValue();

            Assert.IsTrue(values.Count() == 1, "the quantity of values is not expected");
            Assert.IsTrue(values.ElementAt(0) == @"\Software\Microsoft\Windows NT\CurrentVersion", "the value is not expected");
        }
        private List <string> ExecuteSubstringFunction()
        {
            LocalVariableComponent variable       = base.components.First();
            IEnumerable <string>   variableValues = variable.GetValue();

            List <string> resultsOfExpression = new List <string>();

            foreach (string value in variableValues)
            {
                int start = this.component.substring_start;

                string resultOfExpression = value.Substring(start - 1, this.calculateSubstringLength(value));

                resultsOfExpression.Add(resultOfExpression);
            }

            return(resultsOfExpression);
        }
Exemple #16
0
        public void Should_not_be_possible_to_apply_a_EndFunction_with_multiples_components_defined_in_evaluators()
        {
            VariablesTypeVariableLocal_variable localVariable = LocalVariableBuilder
                                                                .CreateTheLocalVariable()
                                                                .WithEnd()
                                                                .WithCharacter(@"\Software")
                                                                .AddLiteralComponent(@"\Software\Microsoft\Windows NT\CurrentVersion")
                                                                .SetInLocalVariable()
                                                                .Build();

            LocalVariableComponentsFactory factory   = new LocalVariableComponentsFactory(systemCharacteristics, definitions.variables);
            LocalVariableComponent         component = factory.GetLocalVariableComponent(localVariable);

            //add new component evaluator in endFunction
            ((LocalVariableFunctionComponent)component).AddComponent(new ArithmeticFunctionComponent(null));

            IEnumerable <string> values = component.GetValue();
        }
Exemple #17
0
        public void Should_be_possible_add_the_character_in_the_end_of_expression_if_the_expression_not_start_with_him()
        {
            VariablesTypeVariableLocal_variable localVariable = LocalVariableBuilder
                                                                .CreateTheLocalVariable()
                                                                .WithEnd()
                                                                .WithCharacter(";")
                                                                .AddLiteralComponent("CurrentVersion")
                                                                .SetInLocalVariable()
                                                                .Build();

            LocalVariableComponentsFactory factory   = new LocalVariableComponentsFactory(systemCharacteristics, definitions.variables);
            LocalVariableComponent         component = factory.GetLocalVariableComponent(localVariable);

            IEnumerable <string> values = component.GetValue();

            Assert.IsTrue(values.Count() == 1, "the quantity of values is not expected");
            Assert.IsTrue(values.ElementAt(0) == "CurrentVersion;", "the quantity of values is not expected");
        }
        private IEnumerable <string> ApplyEndFunction()
        {
            List <string>          values             = new List <string>();
            LocalVariableComponent component          = this.components.First();
            IEnumerable <string>   valuesOfComponents = component.GetValue();

            foreach (string value in valuesOfComponents)
            {
                if (!value.EndsWith(endFunctionType.character))
                {
                    values.Add(value + endFunctionType.character);
                }
                else
                {
                    values.Add(value);
                }
            }
            return(values);
        }
Exemple #19
0
        public void Should_be_possible_to_get_value_of_escaperegex_function_with_LiteralComponent()
        {
            Assert.IsNotNull(definitions, "the definitions was loaded");
            Assert.IsNotNull(systemCharacteristics, "the systemCharacteristics was not loaded");

            VariablesTypeVariableLocal_variable localVariable = LocalVariableBuilder
                                                                .CreateTheLocalVariable()
                                                                .WithEscapeRegex()
                                                                .AddLiteralComponent(@"C:\Windows")
                                                                .SetInLocalVariable()
                                                                .Build();

            LocalVariableComponentsFactory factory = new LocalVariableComponentsFactory(systemCharacteristics, definitions.variables);
            LocalVariableComponent         localVariableComponent = factory.GetLocalVariableComponent(localVariable);
            IEnumerable <string>           values = localVariableComponent.GetValue();

            Assert.IsTrue((values.Count() == 1), "the quantity is not expected");
            Assert.IsTrue(values.ElementAt(0).Equals(@"C:\\Windows"), "the value is not expected");
        }
Exemple #20
0
        public void Should_be_possible_to_get_value_of_escaperegex_function_with_ObjectComponent()
        {
            Assert.IsNotNull(definitions, "the definitions was loaded");
            Assert.IsNotNull(systemCharacteristics, "the systemCharacteristics was not loaded");

            VariablesTypeVariableLocal_variable localVariable = LocalVariableBuilder
                                                                .CreateTheLocalVariable()
                                                                .WithEscapeRegex()
                                                                .AddObjectComponent("oval:org.mitre.oval:obj:3000", "key")
                                                                .SetInLocalVariable()
                                                                .Build();

            LocalVariableComponentsFactory factory = new LocalVariableComponentsFactory(systemCharacteristics, definitions.variables);
            LocalVariableComponent         localVariableComponent = factory.GetLocalVariableComponent(localVariable);
            IEnumerable <string>           values = localVariableComponent.GetValue();

            Assert.IsTrue((values.Count() == 1), "the quantity is not expected");
            Assert.IsTrue(values.ElementAt(0).Equals(@"Software\\Microsoft\\Windows\ NT\\CurrentVersion"), "the value is not expected");
        }
Exemple #21
0
        public void Should_be_possible_to_get_value_of_splitFunction_with_ObjectComponent()
        {
            VariablesTypeVariableLocal_variable localVariable = LocalVariableBuilder.
                                                                CreateTheLocalVariable().
                                                                WithSplit().
                                                                WithDelimeter(".").
                                                                AddObjectComponent("oval:org.mitre.oval:obj:8000", "value").
                                                                SetInLocalVariable().
                                                                Build();

            Assert.IsNotNull(definitions, "the definitions was loaded");
            Assert.IsNotNull(systemCharacteristics, "the systemCharacteristics was not loaded");
            LocalVariableComponentsFactory factory = new LocalVariableComponentsFactory(systemCharacteristics, definitions.variables);
            LocalVariableComponent         localVariableComponent = factory.GetLocalVariableComponent(localVariable);
            IEnumerable <string>           values = localVariableComponent.GetValue();

            Assert.IsTrue((values.Count() == 2), "the quantity is not expected");
            Assert.IsTrue(values.ElementAt(0).ToString() == "4", "the value of first element is not expected");
            Assert.IsTrue(values.ElementAt(1).ToString() == "0", "the value of second element is not expected");
        }
Exemple #22
0
        public void Should_be_possible_to_get_value_of_regexcapture_function_with_ObjectComponent()
        {
            Assert.IsNotNull(definitions, "the definitions was loaded");
            Assert.IsNotNull(systemCharacteristics, "the systemCharacteristics was not loaded");

            VariablesTypeVariableLocal_variable localVariable = LocalVariableBuilder.
                                                                CreateTheLocalVariable().
                                                                WithRegexCapture().
                                                                WithPattern("(B.{4})").
                                                                AddObjectComponent("oval:org.mitre.oval:obj:5000", "name").
                                                                SetInLocalVariable().
                                                                Build();

            LocalVariableComponentsFactory factory = new LocalVariableComponentsFactory(systemCharacteristics, definitions.variables);
            LocalVariableComponent         localVariableComponent = factory.GetLocalVariableComponent(localVariable);
            IEnumerable <string>           values = localVariableComponent.GetValue();

            Assert.IsTrue((values.Count() == 2), "the quantity is not expected");
            Assert.IsTrue(values.ElementAt(0).Equals("Build"), "the value of first element is not expected");
            Assert.IsTrue(values.ElementAt(1).Equals("Build"), "the value of second element is not expected");
        }
        public void Should_be_possible_to_calculate_the_difference_between_dates_with_literal_component_with_differents_formats()
        {
            VariablesTypeVariableLocal_variable localVariable =
                LocalVariableBuilder
                .CreateTheLocalVariable()
                .WithTimeDifference()
                .WithFirstFormat(DateTimeFormatEnumeration.day_month_year)
                .WithSecondFormat(DateTimeFormatEnumeration.month_day_year)
                .AddLiteralComponent("25/09/2009 00:00:00")
                .AddLiteralComponent("09/25/2009 00:00:10")
                .SetInLocalVariable()
                .Build();


            LocalVariableComponentsFactory factory   = new LocalVariableComponentsFactory(systemCharacteristics, definitions.variables);
            LocalVariableComponent         component = factory.GetLocalVariableComponent(localVariable);
            IEnumerable <string>           values    = component.GetValue();

            Assert.IsTrue(values.Count() > 0, "the quantity is not expected");
            Assert.IsTrue(values.ElementAt(0) == "10"); // in seconds
        }
        public void Should_be_possible_to_get_value_of_arithmeticFunction_with_add_operation()

        {
            VariablesTypeVariableLocal_variable localVariableInt = LocalVariableBuilder
                                                                   .CreateTheLocalVariable()
                                                                   .WithArithmetic()
                                                                   .WithArithmeticOperation(ArithmeticEnumeration.add)
                                                                   .AddLiteralComponent(10.ToString(), SimpleDatatypeEnumeration.@int)
                                                                   .AddLiteralComponent(10.ToString(), SimpleDatatypeEnumeration.@int)
                                                                   .SetInLocalVariable()
                                                                   .Build();

            Assert.IsNotNull(definitions, "the definitions was loaded");
            Assert.IsNotNull(systemCharacteristics, "the systemCharacteristics was not loaded");

            LocalVariableComponentsFactory factory   = new LocalVariableComponentsFactory(systemCharacteristics, definitions.variables);
            LocalVariableComponent         component = factory.GetLocalVariableComponent(localVariableInt);

            Assert.IsInstanceOfType(component, typeof(ArithmeticFunctionComponent));
            IEnumerable <string> values = component.GetValue();

            Assert.IsTrue(values.Count() == 1, "the quantity of values is not expected");
            Assert.IsTrue(values.ElementAt(0) == 20.ToString(), "the value is not expected");

            VariablesTypeVariableLocal_variable localVariableFloat = LocalVariableBuilder
                                                                     .CreateTheLocalVariable()
                                                                     .WithArithmetic()
                                                                     .WithArithmeticOperation(ArithmeticEnumeration.add)
                                                                     .AddLiteralComponent(10.1.ToString(), SimpleDatatypeEnumeration.@float)
                                                                     .AddLiteralComponent(10.1.ToString(), SimpleDatatypeEnumeration.@float)
                                                                     .SetInLocalVariable()
                                                                     .Build();

            component = factory.GetLocalVariableComponent(localVariableFloat);
            Assert.IsInstanceOfType(component, typeof(ArithmeticFunctionComponent));
            values = component.GetValue();
            Assert.IsTrue(values.Count() == 1, "the quantity of values is not expected");
            Assert.IsTrue(values.ElementAt(0) == 20.2f.ToString(), "the value is not expected");
        }
        public void Should_be_possible_to_get_value_of_arithmeticFunction_with_multiply_objectComponent_operation()
        {
            VariablesTypeVariableLocal_variable localVariable = LocalVariableBuilder
                                                                .CreateTheLocalVariable()
                                                                .WithArithmetic()
                                                                .WithArithmeticOperation(ArithmeticEnumeration.multiply)
                                                                .AddObjectComponent("oval:org.mitre.oval:obj:3000", "value")
                                                                .AddObjectComponent("oval:org.mitre.oval:obj:8000", "value")
                                                                .SetInLocalVariable()
                                                                .Build();

            Assert.IsNotNull(definitions, "the definitions was loaded");
            Assert.IsNotNull(systemCharacteristics, "the systemCharacteristics was not loaded");

            LocalVariableComponentsFactory factory   = new LocalVariableComponentsFactory(systemCharacteristics, definitions.variables);
            LocalVariableComponent         component = factory.GetLocalVariableComponent(localVariable);

            Assert.IsInstanceOfType(component, typeof(ArithmeticFunctionComponent));
            IEnumerable <string> values = component.GetValue();

            Assert.IsTrue(values.Count() == 1, "the quantity of values is not expected");
            Assert.IsTrue(values.ElementAt(0) == 24.ToString(), "the value is not expected");
        }
Exemple #26
0
        public void Shoud_be_possible_to_get_value_of_splitFunction_with_ObjectComponent_with_two_values()
        {
            VariablesTypeVariableLocal_variable localVariable = LocalVariableBuilder.
                                                                CreateTheLocalVariable().
                                                                WithSplit().
                                                                WithDelimeter(".").
                                                                AddObjectComponent("oval:org.mitre.oval:obj:5000", "value").
                                                                SetInLocalVariable().
                                                                Build();

            Assert.IsNotNull(definitions, "the definitions was loaded");
            Assert.IsNotNull(systemCharacteristics, "the systemCharacteristics was not loaded");
            LocalVariableComponentsFactory factory = new LocalVariableComponentsFactory(systemCharacteristics, definitions.variables);
            LocalVariableComponent         localVariableComponent = factory.GetLocalVariableComponent(localVariable);
            IEnumerable <string>           values = localVariableComponent.GetValue();

            Assert.IsTrue((values.Count() == 6), "the quantity is not expected");
            Assert.IsTrue(values.ElementAt(0).ToString() == "6001", "the value of first element is not expected");
            Assert.IsTrue(values.ElementAt(1).ToString() == "18000", "the value of second element is not expected");
            Assert.IsTrue(values.ElementAt(2).ToString() == "x86fre", "the value of third element is not expected");
            Assert.IsTrue(values.ElementAt(3).ToString() == "longhorn_rtm", "the value of fourth element is not expected");
            Assert.IsTrue(values.ElementAt(4).ToString() == "080118-1840", "the value of fifth element is not expected");
            Assert.IsTrue(values.ElementAt(5).ToString() == "1616", "the value of sixth element is not expected");
        }
Exemple #27
0
        public override IEnumerable <string> GetValue()
        {
            LocalVariableComponent localVariableComponent = this.localVariableComponentFactory.GetLocalVariableComponent(variable);

            return(localVariableComponent.GetValue());
        }
Exemple #28
0
 /// <summary>
 /// Add other components in the function. Ex. LocalVariableObjectComponent, LocalVariableObjectComponent and other Functions
 /// </summary>
 /// <param name="component">The component.</param>
 public void AddComponent(LocalVariableComponent component)
 {
     this.components.Add(component);
 }