Added test for DataRow error
authorShay Rojansky <roji@roji.org>
Mon, 21 Jul 2014 08:44:26 +0000 (08:44 +0000)
committerShay Rojansky <roji@roji.org>
Mon, 21 Jul 2014 09:10:08 +0000 (09:10 +0000)
mcs/class/System.Data/Test/System.Data.Common/DbDataAdapterTest.cs

index c857af2d64bb4307cc1d34266be248121d6215a6..60e6799911c5427f6d77e64610247f24f84297fe 100644 (file)
@@ -225,6 +225,37 @@ sqliteDataAdapter.Update (dataSet, "Primus");
                }
 #endif
 
+                [Test]
+                public void UpdateResetRowErrorCorrectly()
+                {
+                        const string connectionString = "URI = file:./SqliteTest.db; Version = 3";//will be in System.Data directory
+                        using (var dbConnection = new SqliteConnection(connectionString)) {
+                                dbConnection.Open();
+                                var ts = dbConnection.BeginTransaction();
+                                try {
+                                        var da = new SqliteDataAdapter("SELECT * FROM Primus", dbConnection);
+                                        var builder = new SqliteCommandBuilder(da);
+                                        da.UpdateCommand = builder.GetUpdateCommand();
+                                        da.UpdateCommand.Transaction = ts;
+                             
+                                        var ds1 = new DataSet();
+                                        da.Fill(ds1, "Primus");
+
+                                        var table = ds1.Tables[0];
+                                        var row = table.NewRow();
+                                        row["id"] = 10;
+                                        row["name"] = "Bart";
+                                        table.Rows.Add(row);
+
+                                        var ds2 = ds1.GetChanges();
+                                        da.Update(ds2, "Primus");
+                                        Assert.IsFalse(ds2.HasErrors);
+                                } finally {
+                                        ts.Rollback();
+                                }
+                        }
+                }
+
 #endif
 
                class MyAdapter : DbDataAdapter