Exemple #1
0
        // ----------------------------------------------------------------------------------------
        /// <!-- RichDataTable_Copy_test -->
        /// <summary>
        ///
        /// </summary>
        public void RichDataTable_Copy_test()
        {
            Assert.ThingsAbout("RichDataTable", "Copy");

            RichDataTable rt  = SimpleTestTable();
            RichDataTable rt2 = rt.Copy();
            int           row = rt.Count - 1;

            Assert.That(rt2.StrValue(row, 0, "b"), Is.equal_to, rt2.StrValue(row, 0, "a"));
            Assert.That(rt2.IntValue(row, 1, 1), Is.equal_to, rt2.IntValue(row, 1, 0));

            _result += Assert.Conclusion;
        }
 // ----------------------------------------------------------------------------------------
 /// <!-- AddSsnFinal4 -->
 /// <summary>
 ///      Adds a column to the table contining the final N digits of the SSN
 /// </summary>
 /// <param name="table">the table to change</param>
 /// <param name="columnFrom">the current ssn column</param>
 /// <param name="columnTo">the (new) column to put the ssn final 4 in</param>
 /// <returns></returns>
 public static RichDataTable AddSsnFinalN(RichDataTable table, int num, string columnFrom, string columnTo)
 {
     table.Add(columnTo, typeof(string));
     for (int row = 0; row < table.Count; ++row)
     {
         if (num > 0)
         {
             string str = table.StrValue(row, columnFrom, "");
             //string lastX = Regex.Replace(str, "^.*(.{" + num + "})$", "$1");
             string lastX = __.LastNChars(num, str);
             table.Rows[row][columnTo] = lastX;
         }
     }
     return(table);
 }
Exemple #3
0
        // ----------------------------------------------------------------------------------------
        /// <!-- RichDataTable_Add_test -->
        /// <summary>
        ///
        /// </summary>
        public void RichDataTable_Add_test()
        {
            Assert.ThingsAbout("RichDataTable", "Add");

            RichDataTable rt  = SimpleTestTable();
            RichDataTable rt2 = rt.Clone();

            Assert.That(rt2.Columns[1].ColumnName, Is.equal_to, rt.Columns[1].ColumnName);

            rt2.Add(1, rt); // _CopyRowToTable(1, rt2);
            rt2.Add(0, rt); // _CopyRowToTable(0, rt2);
            int age1 = rt.IntValue(1, 1, 1);
            int age2 = rt2.IntValue(0, 1, 2);

            Assert.That(age2, Is.equal_to, age1);
            string name1 = rt.StrValue(0, 0, "a");
            string name2 = rt2.StrValue(1, 0, "b");

            Assert.That(name2, Is.equal_to, name1);

            _result += Assert.Conclusion;
        }