/// <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> /// Initializes a new instance of the LuxUnitTest class. This constructor can only be called by subclasses. /// </summary> /// <param name="session">MSI session where the unit test will be running</param> /// <param name="logger">Logger to record test output</param> /// <param name="wixUnitTestId">Wix unit test id</param> /// <param name="condition">MSI condition to determine if test should run</param> protected LuxUnitTest(Session session, LuxLogger logger, string wixUnitTestId, string condition) { this.Session = session; this.Logger = logger; this.WixUnitTestId = wixUnitTestId; this.Condition = condition; }
/// <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); } }
public static ActionResult WixRunImmediateUnitTests(Session session) { LuxUnitTestFactory factory = new LuxUnitTestFactory(); LuxLogger logger = new LuxLogger(session); string sql = String.Concat("SELECT `WixUnitTest`, `CustomAction_`, `Property`, `Operator`, `Value`, `Expression`, `Condition`, `ValueSeparator`, `NameValueSeparator`, `Index` FROM ", Constants.LuxTableName, " WHERE `Mutation` IS NULL"); string mutation = session[Constants.LuxMutationRunningProperty]; if (!String.IsNullOrEmpty(mutation)) { sql = String.Concat(sql, " OR `Mutation` = '", mutation, "'"); } using (View view = session.Database.OpenView(sql)) { view.Execute(); foreach (Record rec in view) { using (rec) { LuxUnitTest unitTest = factory.CreateUnitTest(session, rec, logger); if (null != unitTest) { if (unitTest.IsTestConditionMet()) { unitTest.RunTest(); } unitTest.LogResult(); } } } } return(ActionResult.UserExit); }
/// <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; }
/// <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); }
/// <summary> /// Initializes a new instance of the LuxExpressionUnitTest 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="expression">Expression to evaluate as true or false</param> public LuxExpressionUnitTest(Session session, LuxLogger logger, string wixUnitTestId, string condition, string expression) : base(session, logger, wixUnitTestId, condition) { this.expression = expression; }