Пример #1
0
 /// <summary>
 /// Figures out the test type based on which columns (input parameters) are non-null for a
 /// particular row in the LuxCustomAction MSI table.
 /// </summary>
 /// <param name="expression">Expression from the unit test row in the LuxUnitTest MSi table.</param>
 /// <param name="property">Property from the unit test row in the LuxUnitTest MSi table.</param>
 /// <param name="op">Operation from the unit test row in the LuxUnitTest MSi table.</param>
 /// <param name="index">Index from the unit test row in the LuxUnitTest MSi table.</param>
 /// <param name="valueSeparator">Value separator from the unit test row in the LuxUnitTest MSi table.</param>
 /// <param name="nameValueSeparator">Name/value separator from the unit test row in the LuxUnitTest MSi table.</param>
 /// <returns>The correct test type, or TestType.Unknown if unable to figure out the test from the non-null inputs.</returns>
 private TestType DetermineTestType(string expression, string property, LuxOperator op, string index, string valueSeparator, string nameValueSeparator)
 {
     // Expression
     if (!string.IsNullOrEmpty(expression))
     {
         return(TestType.Expression);
     }
     else if (!string.IsNullOrEmpty(property) &&
              op > 0 &&
              !string.IsNullOrEmpty(index) &&
              !string.IsNullOrEmpty(valueSeparator))
     {
         return(TestType.DelimitedList);
     }
     else if (!string.IsNullOrEmpty(property) &&
              op > 0 &&
              !string.IsNullOrEmpty(index) &&
              !string.IsNullOrEmpty(nameValueSeparator))
     {
         return(TestType.DelimitedKeyValue);
     }
     else if (!string.IsNullOrEmpty(property) &&
              op > 0)
     {
         return(TestType.PropertyValue);
     }
     else
     {
         return(TestType.Unknown);
     }
 }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the LuxPropertyValueUnitTest class
 /// </summary>
 /// <param name="session">MSI session handle</param>
 /// <param name="logger">Logger to capture test output</param>
 /// <param name="wixUnitTestId">Wix unit test id</param>
 /// <param name="condition">MSI condition to determine if the test should run</param>
 /// <param name="property">MSI property which has a value consisting of delimited key/value pairs.</param>
 /// <param name="op">Comparison operator type</param>
 /// <param name="value">Expected value</param>
 public LuxPropertyValueUnitTest(Session session, LuxLogger logger, string wixUnitTestId, string condition, string property, LuxOperator op, string value)
     : base(session, logger, wixUnitTestId, condition)
 {
     this.property      = property;
     this.op            = op;
     this.expectedValue = value;
 }
Пример #3
0
        /// <summary>
        /// Creates the appropriate unit test class and returns the base class.
        /// </summary>
        /// <param name="session">MSI session handle.</param>
        /// <param name="record">Record from the LuxCustomAction MSI table.</param>
        /// <param name="logger">Logger to record unit test output.</param>
        /// <returns>A Lux unit test appropriate for the given record. Returns null on error.</returns>
        public LuxUnitTest CreateUnitTest(Session session, Record record, LuxLogger logger)
        {
            string      wixUnitTestId      = record["WixUnitTest"] as string;
            string      customAction       = record["CustomAction_"] as string;
            string      property           = record["Property"] as string;
            LuxOperator op                 = (LuxOperator)Convert.ToInt16(record["Operator"] as object);
            string      value              = record["Value"] as string;
            string      expression         = record["Expression"] as string;
            string      condition          = record["Condition"] as string;
            string      valueSeparator     = record["ValueSeparator"] as string;
            string      nameValueSeparator = record["NameValueSeparator"] as string;
            string      index              = record["Index"] as string;

            switch (this.DetermineTestType(expression, property, op, index, valueSeparator, nameValueSeparator))
            {
            case TestType.Expression:
                return(new LuxExpressionUnitTest(session, logger, wixUnitTestId, condition, expression));

            case TestType.PropertyValue:
                return(new LuxPropertyValueUnitTest(session, logger, wixUnitTestId, condition, property, op, value));

            case TestType.DelimitedList:
                return(new LuxDelimitedListUnitTest(session, logger, wixUnitTestId, condition, property, op, value, valueSeparator, index));

            case TestType.DelimitedKeyValue:
                return(new LuxDelimitedKeyValueUnitTest(session, logger, wixUnitTestId, condition, property, op, value, nameValueSeparator, index));

            default:
                logger.Log(Constants.TestNotCreated, wixUnitTestId);
                return(null);
            }
        }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the LuxDelimitedKeyValueUnitTest class
 /// </summary>
 /// <param name="session">MSI session handle</param>
 /// <param name="logger">Logger to capture test output</param>
 /// <param name="wixUnitTestId">Wix unit test id</param>
 /// <param name="condition">MSI condition to determine if the test should run</param>
 /// <param name="property">MSI property which has a value consisting of delimited key/value pairs.</param>
 /// <param name="op">Comparison operator type</param>
 /// <param name="value">Expected value</param>
 /// <param name="nameValueSeparator">Delimiter char/string</param>
 /// <param name="index">Key in the key/value pairings to test</param>
 public LuxDelimitedKeyValueUnitTest(Session session, LuxLogger logger, string wixUnitTestId, string condition, string property, LuxOperator op, string value, string nameValueSeparator, string index)
     : base(session, logger, wixUnitTestId, condition, property, op, value)
 {
     this.nameValueSeparator = nameValueSeparator;
     this.index = index;
 }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the LuxDelimitedListUnitTest class
 /// </summary>
 /// <param name="session">MSI session handle</param>
 /// <param name="logger">Logger to capture test output</param>
 /// <param name="wixUnitTestId">Wix unit test id</param>
 /// <param name="condition">MSI condition to determine if the test should run</param>
 /// <param name="property">MSI property which has a value consisting of delimited key/value pairs.</param>
 /// <param name="op">Comparison operator type</param>
 /// <param name="value">Expected value</param>
 /// <param name="valueSeparator">Delimiter char/string</param>
 /// <param name="index">Index of the value in the delimited value array to test</param>
 public LuxDelimitedListUnitTest(Session session, LuxLogger logger, string wixUnitTestId, string condition, string property, LuxOperator op, string value, string valueSeparator, string index)
     : base(session, logger, wixUnitTestId, condition, property, op, value)
 {
     this.valueSeparator = valueSeparator;
     this.index          = Convert.ToInt32(index);
 }
Пример #6
0
 /// <summary>
 /// Initializes a new instance of the LuxDelimitedKeyValueUnitTest class
 /// </summary>
 /// <param name="session">MSI session handle</param>
 /// <param name="logger">Logger to capture test output</param>
 /// <param name="wixUnitTestId">Wix unit test id</param>
 /// <param name="condition">MSI condition to determine if the test should run</param>
 /// <param name="property">MSI property which has a value consisting of delimited key/value pairs.</param>
 /// <param name="op">Comparison operator type</param>
 /// <param name="value">Expected value</param>
 /// <param name="nameValueSeparator">Delimiter char/string</param>
 /// <param name="index">Key in the key/value pairings to test</param>
 public LuxDelimitedKeyValueUnitTest(Session session, LuxLogger logger, string wixUnitTestId, string condition, string property, LuxOperator op, string value, string nameValueSeparator, string index)
     : base(session, logger, wixUnitTestId, condition, property, op, value)
 {
     this.nameValueSeparator = nameValueSeparator;
     this.index = index;
 }
Пример #7
0
 /// <summary>
 /// Initializes a new instance of the LuxDelimitedListUnitTest class
 /// </summary>
 /// <param name="session">MSI session handle</param>
 /// <param name="logger">Logger to capture test output</param>
 /// <param name="wixUnitTestId">Wix unit test id</param>
 /// <param name="condition">MSI condition to determine if the test should run</param>
 /// <param name="property">MSI property which has a value consisting of delimited key/value pairs.</param>
 /// <param name="op">Comparison operator type</param>
 /// <param name="value">Expected value</param>
 /// <param name="valueSeparator">Delimiter char/string</param>
 /// <param name="index">Index of the value in the delimited value array to test</param>
 public LuxDelimitedListUnitTest(Session session, LuxLogger logger, string wixUnitTestId, string condition, string property, LuxOperator op, string value, string valueSeparator, string index)
     : base(session, logger, wixUnitTestId, condition, property, op, value)
 {
     this.valueSeparator = valueSeparator;
     this.index = Convert.ToInt32(index);
 }
Пример #8
0
 /// <summary>
 /// Initializes a new instance of the LuxPropertyValueUnitTest class
 /// </summary>
 /// <param name="session">MSI session handle</param>
 /// <param name="logger">Logger to capture test output</param>
 /// <param name="wixUnitTestId">Wix unit test id</param>
 /// <param name="condition">MSI condition to determine if the test should run</param>
 /// <param name="property">MSI property which has a value consisting of delimited key/value pairs.</param>
 /// <param name="op">Comparison operator type</param>
 /// <param name="value">Expected value</param>
 public LuxPropertyValueUnitTest(Session session, LuxLogger logger, string wixUnitTestId, string condition, string property, LuxOperator op, string value)
     : base(session, logger, wixUnitTestId, condition)
 {
     this.property = property;
     this.op = op;
     this.expectedValue = value;
 }
        /// <summary>
        /// Figures out the test type based on which columns (input parameters) are non-null for a 
        /// particular row in the LuxCustomAction MSI table.
        /// </summary>
        /// <param name="expression">Expression from the unit test row in the LuxUnitTest MSi table.</param>
        /// <param name="property">Property from the unit test row in the LuxUnitTest MSi table.</param>
        /// <param name="op">Operation from the unit test row in the LuxUnitTest MSi table.</param>
        /// <param name="index">Index from the unit test row in the LuxUnitTest MSi table.</param>
        /// <param name="valueSeparator">Value separator from the unit test row in the LuxUnitTest MSi table.</param>
        /// <param name="nameValueSeparator">Name/value separator from the unit test row in the LuxUnitTest MSi table.</param>
        /// <returns>The correct test type, or TestType.Unknown if unable to figure out the test from the non-null inputs.</returns>
        private TestType DetermineTestType(string expression, string property, LuxOperator op, string index, string valueSeparator, string nameValueSeparator)
        {
            // Expression
            if (!string.IsNullOrEmpty(expression))
            {
                return TestType.Expression;
            }
            else if (!string.IsNullOrEmpty(property) &&
                     op > 0 &&
                     !string.IsNullOrEmpty(index) &&
                     !string.IsNullOrEmpty(valueSeparator))
            {
                return TestType.DelimitedList;
            }
            else if (!string.IsNullOrEmpty(property) &&
                     op > 0 &&
                     !string.IsNullOrEmpty(index) &&
                     !string.IsNullOrEmpty(nameValueSeparator))
            {
                return TestType.DelimitedKeyValue;
            }
            else if (!string.IsNullOrEmpty(property) &&
                     op > 0)
            {
                return TestType.PropertyValue;
            }
            else
            {
                return TestType.Unknown;
            }

        }