示例#1
0
        public void DmTable_RejectChanges()
        {
            tbl.AcceptChanges();

            var dmRow = tbl.Rows[0];

            dmRow["CustomerID"] = 2;

            tbl.RejectChanges();

            Assert.Equal(1, dmRow["CustomerID"]);
            Assert.Equal(DmRowState.Unchanged, dmRow.RowState);

            // Try to reject changes after creating a table, with no acceptchanges
            var tbl3 = new DmTable();
            var id3  = new DmColumn <Int32>("ServiceTicketID");

            id3.IsAutoIncrement = true;
            tbl3.Columns.Add(id3);
            var key3 = new DmKey(new DmColumn[] { id3 });

            tbl3.PrimaryKey = key3;
            tbl3.Columns.Add(new DmColumn <string>("Title"));

            var st3 = tbl3.NewRow();

            st3["Title"] = "Titre AER";
            tbl3.Rows.Add(st3);

            // SInce we didn't AcceptChanges, raise an error
            Assert.Throws <Exception>(() => tbl3.RejectChanges());
        }