コード例 #1
0
ファイル: Verifier.cs プロジェクト: naderm1991/tutorial-wix
        /// <summary>
        /// Given a list of column names, and expected values, the method composes an SQL query against the specified file;
        /// the query results has to match to exactly one row; if not an assert is raised.
        /// </summary>
        /// <param name="msiFile">MSI File name</param>
        /// <param name="tableName">Table to query</param>
        /// <param name="columns">Optional list of key value pairs represinting fields names and expected values</param>
        public static void VerifyTableData(string msiFile, MSITables table, params TableRow[] columns)
        {
            if (null == columns || columns.Length < 1)
            {
                throw new ArgumentException("Columns can not be empty.", "Columns");
            }

            string query = string.Format("SELECT * FROM `{0}` WHERE ", table.ToString());

            for (int i = 0; i < columns.Length; i++)
            {
                TableRow pair = columns[i];

                query += string.Format(" `{0}` ", pair.Key);
                if (pair.IsString)
                {
                    query += string.Format(" = '{0}' ", pair.Value);
                }
                else
                {
                    if (string.IsNullOrEmpty(pair.Value))
                    {
                        query += string.Format(" IS NULL ", pair.Value);
                    }
                    else
                    {
                        query += string.Format(" = {0} ", pair.Value);
                    }
                }

                if (i < (columns.Length - 1))
                {
                    query += " AND ";
                }
            }

            List <DTF.Record> result = Verifier.QueryAllRecords(msiFile, query);

            Assert.True(1 == result.Count, string.Format("Result count: {0} Rows, Expected: 1 Rows. Query:'{1}', MSI File '{2}'", result.Count, query, msiFile));
        }
コード例 #2
0
ファイル: Verifier.cs プロジェクト: zooba/wix3
        /// <summary>
        /// Given a list of column names, and expected values, the method composes an SQL query against the specified file; 
        /// the query results has to match to exactly one row; if not an assert is raised.
        /// </summary>
        /// <param name="msiFile">MSI File name</param>
        /// <param name="tableName">Table to query</param>
        /// <param name="columns">Optional list of key value pairs represinting fields names and expected values</param>
        public static void VerifyTableData(string msiFile, MSITables table, params TableRow[] columns)
        {
            if (null == columns || columns.Length < 1)
            {
                throw new ArgumentException("Columns can not be empty.","Columns");
            }

            string query = string.Format("SELECT * FROM `{0}` WHERE ", table.ToString());

            for (int i = 0; i < columns.Length; i++)
            {
                TableRow pair = columns[i];

                query += string.Format(" `{0}` ", pair.Key);
                if (pair.IsString)
                {
                    query += string.Format(" = '{0}' ", pair.Value);
                }
                else
                {
                    if (string.IsNullOrEmpty(pair.Value))
                    {
                        query += string.Format(" IS NULL ", pair.Value);
                    }
                    else
                    {
                        query += string.Format(" = {0} ", pair.Value);
                    }
                }

                if (i < (columns.Length - 1))
                {
                    query += " AND ";
                }
            }

            List<DTF.Record> result = Verifier.QueryAllRecords(msiFile, query);
            Assert.True(1 == result.Count, string.Format("Result count: {0} Rows, Expected: 1 Rows. Query:'{1}', MSI File '{2}'", result.Count, query, msiFile));
        }