[System.Data] Fixes tests build with mobile profiles
[mono.git] / mcs / class / System.Data / Test / System.Data.Odbc / OdbcDataAdapterTest.cs
1 //
2 // OdbcDataAdapterTest.cs - NUnit Test Cases for testing the
3 //                        OdbcDataAdapter class
4 // Author:
5 //      Gert Driesen (drieseng@users.sourceforge.net)
6 //
7 // Copyright (c) 2007 Gert Driesen
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28
29 #if !NO_ODBC
30
31 using System;
32 using System.Data;
33 using System.Data.Odbc;
34 using System.Data.OleDb;
35
36 using NUnit.Framework;
37
38 namespace MonoTests.System.Data.Odbc
39 {
40         [TestFixture]
41         public class OdbcDataAdapterTest
42         {
43                 [Test] // OdbcDataAdapter ()
44                 public void Constructor1 ()
45                 {
46                         OdbcDataAdapter da = new OdbcDataAdapter ();
47                         Assert.IsTrue (da.AcceptChangesDuringFill, "#1");
48                         Assert.IsTrue (da.AcceptChangesDuringUpdate, "#2");
49                         Assert.IsNull (da.Container, "#3");
50                         Assert.IsFalse (da.ContinueUpdateOnError, "#4");
51                         Assert.IsNull (da.DeleteCommand, "#5");
52                         Assert.AreEqual (LoadOption.OverwriteChanges, da.FillLoadOption, "#6");
53                         Assert.IsNull (da.InsertCommand, "#7");
54                         Assert.AreEqual (MissingMappingAction.Passthrough, da.MissingMappingAction, "#8");
55                         Assert.AreEqual (MissingSchemaAction.Add, da.MissingSchemaAction, "#9");
56                         Assert.IsFalse (da.ReturnProviderSpecificTypes, "#10");
57                         Assert.IsNull (da.SelectCommand, "#11");
58                         Assert.IsNull (da.Site, "#12");
59                         Assert.IsNotNull (da.TableMappings, "#13");
60                         Assert.AreEqual (0, da.TableMappings.Count, "#14");
61                         Assert.AreEqual (1, da.UpdateBatchSize, "#15");
62                         Assert.IsNull (da.UpdateCommand, "#16");
63                 }
64
65                 [Test] // OdbcDataAdapter (OdbcCommand)
66                 public void Constructor2 ()
67                 {
68                         OdbcCommand cmd = new OdbcCommand ();
69                         OdbcDataAdapter da = new OdbcDataAdapter (cmd);
70                         Assert.IsTrue (da.AcceptChangesDuringFill, "#1");
71                         Assert.IsTrue (da.AcceptChangesDuringUpdate, "#2");
72                         Assert.IsNull (da.Container, "#3");
73                         Assert.IsFalse (da.ContinueUpdateOnError, "#4");
74                         Assert.IsNull (da.DeleteCommand, "#5");
75                         Assert.AreEqual (LoadOption.OverwriteChanges, da.FillLoadOption, "#6");
76                         Assert.IsNull (da.InsertCommand, "#7");
77                         Assert.AreEqual (MissingMappingAction.Passthrough, da.MissingMappingAction, "#8");
78                         Assert.AreEqual (MissingSchemaAction.Add, da.MissingSchemaAction, "#9");
79                         Assert.IsFalse (da.ReturnProviderSpecificTypes, "#10");
80                         Assert.IsNotNull (da.SelectCommand, "#11");
81                         Assert.AreSame (cmd, da.SelectCommand, "#12");
82                         Assert.IsNull (da.Site, "#13");
83                         Assert.IsNotNull (da.TableMappings, "#14");
84                         Assert.AreEqual (0, da.TableMappings.Count, "#15");
85                         Assert.AreEqual (1, da.UpdateBatchSize, "#16");
86                         Assert.IsNull (da.UpdateCommand, "#17");
87                 }
88
89                 [Test] // OdbcDataAdapter (OdbcCommand)
90                 public void Constructor2_SelectCommand_Null ()
91                 {
92                         OdbcDataAdapter da = new OdbcDataAdapter ((OdbcCommand) null);
93                         Assert.IsTrue (da.AcceptChangesDuringFill, "#1");
94                         Assert.IsTrue (da.AcceptChangesDuringUpdate, "#2");
95                         Assert.IsNull (da.Container, "#3");
96                         Assert.IsFalse (da.ContinueUpdateOnError, "#4");
97                         Assert.IsNull (da.DeleteCommand, "#5");
98                         Assert.AreEqual (LoadOption.OverwriteChanges, da.FillLoadOption, "#6");
99                         Assert.IsNull (da.InsertCommand, "#7");
100                         Assert.AreEqual (MissingMappingAction.Passthrough, da.MissingMappingAction, "#8");
101                         Assert.AreEqual (MissingSchemaAction.Add, da.MissingSchemaAction, "#9");
102                         Assert.IsFalse (da.ReturnProviderSpecificTypes, "#10");
103                         Assert.IsNull (da.SelectCommand, "#11");
104                         Assert.IsNull (da.Site, "#12");
105                         Assert.IsNotNull (da.TableMappings, "#13");
106                         Assert.AreEqual (0, da.TableMappings.Count, "#14");
107                         Assert.AreEqual (1, da.UpdateBatchSize, "#15");
108                         Assert.IsNull (da.UpdateCommand, "#16");
109                 }
110
111                 [Test] // OdbcDataAdapter (string, OdbcCommand)
112                 public void Constructor3 ()
113                 {
114                         string selectCommandText = "SELECT * FROM Authors";
115                         OdbcConnection selectConnection = new OdbcConnection ();
116
117                         OdbcDataAdapter da = new OdbcDataAdapter (selectCommandText,
118                                 selectConnection);
119                         Assert.IsTrue (da.AcceptChangesDuringFill, "#1");
120                         Assert.IsTrue (da.AcceptChangesDuringUpdate, "#2");
121                         Assert.IsNull (da.Container, "#3");
122                         Assert.IsFalse (da.ContinueUpdateOnError, "#4");
123                         Assert.IsNull (da.DeleteCommand, "#5");
124                         Assert.AreEqual (LoadOption.OverwriteChanges, da.FillLoadOption, "#6");
125                         Assert.IsNull (da.InsertCommand, "#7");
126                         Assert.AreEqual (MissingMappingAction.Passthrough, da.MissingMappingAction, "#8");
127                         Assert.AreEqual (MissingSchemaAction.Add, da.MissingSchemaAction, "#9");
128                         Assert.IsFalse (da.ReturnProviderSpecificTypes, "#10");
129                         Assert.IsNotNull (da.SelectCommand, "#11");
130                         Assert.AreSame (selectCommandText, da.SelectCommand.CommandText, "#12");
131                         Assert.AreSame (selectConnection, da.SelectCommand.Connection, "#13");
132                         Assert.IsNull (da.Site, "#14");
133                         Assert.IsNotNull (da.TableMappings, "#15");
134                         Assert.AreEqual (0, da.TableMappings.Count, "#16");
135                         Assert.AreEqual (1, da.UpdateBatchSize, "#17");
136                         Assert.IsNull (da.UpdateCommand, "#18");
137                 }
138
139                 [Test] // OdbcDataAdapter (string, OdbcConnection)
140                 public void Constructor3_SelectCommandText_Null ()
141                 {
142                         OdbcConnection selectConnection = new OdbcConnection ();
143
144                         OdbcDataAdapter da = new OdbcDataAdapter ((string) null,
145                                 selectConnection);
146                         Assert.IsTrue (da.AcceptChangesDuringFill, "#1");
147                         Assert.IsTrue (da.AcceptChangesDuringUpdate, "#2");
148                         Assert.IsNull (da.Container, "#3");
149                         Assert.IsFalse (da.ContinueUpdateOnError, "#4");
150                         Assert.IsNull (da.DeleteCommand, "#5");
151                         Assert.AreEqual (LoadOption.OverwriteChanges, da.FillLoadOption, "#6");
152                         Assert.IsNull (da.InsertCommand, "#7");
153                         Assert.AreEqual (MissingMappingAction.Passthrough, da.MissingMappingAction, "#8");
154                         Assert.AreEqual (MissingSchemaAction.Add, da.MissingSchemaAction, "#9");
155                         Assert.IsFalse (da.ReturnProviderSpecificTypes, "#10");
156                         Assert.IsNotNull (da.SelectCommand, "#11");
157                         Assert.IsNotNull (da.SelectCommand.CommandText, "#12");
158                         Assert.AreEqual (string.Empty, da.SelectCommand.CommandText, "#13");
159                         Assert.AreSame (selectConnection, da.SelectCommand.Connection, "#14");
160                         Assert.IsNull (da.Site, "#15");
161                         Assert.IsNotNull (da.TableMappings, "#16");
162                         Assert.AreEqual (0, da.TableMappings.Count, "#17");
163                         Assert.AreEqual (1, da.UpdateBatchSize, "#18");
164                         Assert.IsNull (da.UpdateCommand, "#19");
165                 }
166
167                 [Test] // OdbcDataAdapter (string, OdbcConnection)
168                 public void Constructor3_SelectConnection_Null ()
169                 {
170                         string selectCommandText = "SELECT * FROM Authors";
171
172                         OdbcDataAdapter da = new OdbcDataAdapter (selectCommandText,
173                                 (OdbcConnection) null);
174                         Assert.IsTrue (da.AcceptChangesDuringFill, "#1");
175                         Assert.IsTrue (da.AcceptChangesDuringUpdate, "#2");
176                         Assert.IsNull (da.Container, "#3");
177                         Assert.IsFalse (da.ContinueUpdateOnError, "#4");
178                         Assert.IsNull (da.DeleteCommand, "#5");
179                         Assert.AreEqual (LoadOption.OverwriteChanges, da.FillLoadOption, "#6");
180                         Assert.IsNull (da.InsertCommand, "#7");
181                         Assert.AreEqual (MissingMappingAction.Passthrough, da.MissingMappingAction, "#8");
182                         Assert.AreEqual (MissingSchemaAction.Add, da.MissingSchemaAction, "#9");
183                         Assert.IsFalse (da.ReturnProviderSpecificTypes, "#10");
184                         Assert.IsNotNull (da.SelectCommand, "#11");
185                         Assert.AreSame (selectCommandText, da.SelectCommand.CommandText, "#12");
186                         Assert.IsNull (da.SelectCommand.Connection, "#13");
187                         Assert.IsNull (da.Site, "#14");
188                         Assert.IsNotNull (da.TableMappings, "#15");
189                         Assert.AreEqual (0, da.TableMappings.Count, "#16");
190                         Assert.AreEqual (1, da.UpdateBatchSize, "#17");
191                         Assert.IsNull (da.UpdateCommand, "#18");
192                 }
193
194                 [Test] // OdbcDataAdapter (string, string)]
195                 public void Constructor4 ()
196                 {
197                         string selectCommandText = "SELECT * FROM Authors";
198                         string selectConnectionString = "Provider=SQLOLEDB;Data Source=SQLSRV;";
199
200                         OdbcDataAdapter da = new OdbcDataAdapter (selectCommandText,
201                                 selectConnectionString);
202                         Assert.IsTrue (da.AcceptChangesDuringFill, "#1");
203                         Assert.IsTrue (da.AcceptChangesDuringUpdate, "#2");
204                         Assert.IsNull (da.Container, "#3");
205                         Assert.IsFalse (da.ContinueUpdateOnError, "#4");
206                         Assert.IsNull (da.DeleteCommand, "#5");
207                         Assert.AreEqual (LoadOption.OverwriteChanges, da.FillLoadOption, "#6");
208                         Assert.IsNull (da.InsertCommand, "#7");
209                         Assert.AreEqual (MissingMappingAction.Passthrough, da.MissingMappingAction, "#8");
210                         Assert.AreEqual (MissingSchemaAction.Add, da.MissingSchemaAction, "#9");
211                         Assert.IsFalse (da.ReturnProviderSpecificTypes, "#10");
212                         Assert.IsNotNull (da.SelectCommand, "#11");
213                         Assert.AreSame (selectCommandText, da.SelectCommand.CommandText, "#12");
214                         Assert.IsNotNull (da.SelectCommand.Connection, "#13");
215                         Assert.AreEqual (selectConnectionString, da.SelectCommand.Connection.ConnectionString, "#14");
216                         Assert.IsNull (da.Site, "#15");
217                         Assert.IsNotNull (da.TableMappings, "#16");
218                         Assert.AreEqual (0, da.TableMappings.Count, "#17");
219                         Assert.AreEqual (1, da.UpdateBatchSize, "#18");
220                         Assert.IsNull (da.UpdateCommand, "#19");
221                 }
222
223                 [Test] // OdbcDataAdapter (string, string)]
224                 public void Constructor4_SelectCommandText_Null ()
225                 {
226                         string selectConnectionString = "Provider=SQLOLEDB;Data Source=SQLSRV;";
227
228                         OdbcDataAdapter da = new OdbcDataAdapter ((string) null,
229                                 selectConnectionString);
230                         Assert.IsTrue (da.AcceptChangesDuringFill, "#1");
231                         Assert.IsTrue (da.AcceptChangesDuringUpdate, "#2");
232                         Assert.IsNull (da.Container, "#3");
233                         Assert.IsFalse (da.ContinueUpdateOnError, "#4");
234                         Assert.IsNull (da.DeleteCommand, "#5");
235                         Assert.AreEqual (LoadOption.OverwriteChanges, da.FillLoadOption, "#6");
236                         Assert.IsNull (da.InsertCommand, "#7");
237                         Assert.AreEqual (MissingMappingAction.Passthrough, da.MissingMappingAction, "#8");
238                         Assert.AreEqual (MissingSchemaAction.Add, da.MissingSchemaAction, "#9");
239                         Assert.IsFalse (da.ReturnProviderSpecificTypes, "#10");
240                         Assert.IsNotNull (da.SelectCommand, "#11");
241                         Assert.IsNotNull (da.SelectCommand.CommandText, "#12");
242                         Assert.AreEqual (string.Empty, da.SelectCommand.CommandText, "#13");
243                         Assert.IsNotNull (da.SelectCommand.Connection, "#14");
244                         Assert.AreEqual (selectConnectionString, da.SelectCommand.Connection.ConnectionString, "#15");
245                         Assert.IsNull (da.Site, "#16");
246                         Assert.IsNotNull (da.TableMappings, "#17");
247                         Assert.AreEqual (0, da.TableMappings.Count, "#18");
248                         Assert.AreEqual (1, da.UpdateBatchSize, "#19");
249                         Assert.IsNull (da.UpdateCommand, "#20");
250                 }
251
252                 [Test] // OdbcDataAdapter (string, string)]
253                 public void Constructor4_SelectConnectionString_Null ()
254                 {
255                         string selectCommandText = "SELECT * FROM Authors";
256
257                         OdbcDataAdapter da = new OdbcDataAdapter (selectCommandText,
258                                 (string) null);
259                         Assert.IsTrue (da.AcceptChangesDuringFill, "#1");
260                         Assert.IsTrue (da.AcceptChangesDuringUpdate, "#2");
261                         Assert.IsNull (da.Container, "#3");
262                         Assert.IsFalse (da.ContinueUpdateOnError, "#4");
263                         Assert.IsNull (da.DeleteCommand, "#5");
264                         Assert.AreEqual (LoadOption.OverwriteChanges, da.FillLoadOption, "#6");
265                         Assert.IsNull (da.InsertCommand, "#7");
266                         Assert.AreEqual (MissingMappingAction.Passthrough, da.MissingMappingAction, "#8");
267                         Assert.AreEqual (MissingSchemaAction.Add, da.MissingSchemaAction, "#9");
268                         Assert.IsFalse (da.ReturnProviderSpecificTypes, "#10");
269                         Assert.IsNotNull (da.SelectCommand, "#11");
270                         Assert.AreSame (selectCommandText, da.SelectCommand.CommandText, "#12");
271                         Assert.IsNotNull (da.SelectCommand.Connection, "#14");
272                         Assert.AreEqual (string.Empty, da.SelectCommand.Connection.ConnectionString, "#15");
273                         Assert.IsNull (da.Site, "#16");
274                         Assert.IsNotNull (da.TableMappings, "#17");
275                         Assert.AreEqual (0, da.TableMappings.Count, "#18");
276                         Assert.AreEqual (1, da.UpdateBatchSize, "#19");
277                         Assert.IsNull (da.UpdateCommand, "#20");
278                 }
279
280                 [Test]
281                 public void DeleteCommand ()
282                 {
283                         OdbcDataAdapter da = new OdbcDataAdapter ();
284                         OdbcCommand cmd1 = new OdbcCommand ();
285                         OdbcCommand cmd2 = new OdbcCommand ();
286
287                         da.DeleteCommand = cmd1;
288                         Assert.AreSame (cmd1, da.DeleteCommand, "#1");
289                         da.DeleteCommand = cmd2;
290                         Assert.AreSame (cmd2, da.DeleteCommand, "#2");
291                         da.DeleteCommand = null;
292                         Assert.IsNull (da.DeleteCommand, "#3");
293                 }
294
295                 [Test]
296                 public void DeleteCommand_IDbDataAdapter ()
297                 {
298                         IDbDataAdapter da = new OdbcDataAdapter ();
299                         OdbcCommand cmd1 = new OdbcCommand ();
300                         OdbcCommand cmd2 = new OdbcCommand ();
301
302                         da.DeleteCommand = cmd1;
303                         Assert.AreSame (cmd1, da.DeleteCommand, "#A1");
304                         da.DeleteCommand = cmd2;
305                         Assert.AreSame (cmd2, da.DeleteCommand, "#A2");
306                         da.DeleteCommand = null;
307                         Assert.IsNull (da.DeleteCommand, "#A3");
308
309                         try {
310                                 da.DeleteCommand = new OleDbCommand ();
311                                 Assert.Fail ("#B1");
312                         } catch (InvalidCastException ex) {
313                                 Assert.AreEqual (typeof (InvalidCastException), ex.GetType (), "#B2");
314                                 Assert.IsNull (ex.InnerException, "#B3");
315                                 Assert.IsNotNull (ex.Message, "#B4");
316                         }
317                 }
318
319                 [Test]
320                 public void Dispose ()
321                 {
322                         OdbcDataAdapter da = new OdbcDataAdapter ();
323                         da.DeleteCommand = new OdbcCommand ();
324                         da.InsertCommand = new OdbcCommand ();
325                         da.SelectCommand = new OdbcCommand ();
326                         da.UpdateCommand = new OdbcCommand ();
327                         da.Dispose ();
328
329                         Assert.IsNull (da.DeleteCommand, "#1");
330                         Assert.IsNull (da.InsertCommand, "#2");
331                         Assert.IsNull (da.SelectCommand, "#3");
332                         Assert.IsNotNull (da.TableMappings, "#4");
333                         Assert.AreEqual (0, da.TableMappings.Count, "#5");
334                         Assert.IsNull (da.UpdateCommand, "#6");
335                 }
336
337                 [Test]
338                 public void InsertCommand ()
339                 {
340                         OdbcDataAdapter da = new OdbcDataAdapter ();
341                         OdbcCommand cmd1 = new OdbcCommand ();
342                         OdbcCommand cmd2 = new OdbcCommand ();
343
344                         da.InsertCommand = cmd1;
345                         Assert.AreSame (cmd1, da.InsertCommand, "#1");
346                         da.InsertCommand = cmd2;
347                         Assert.AreSame (cmd2, da.InsertCommand, "#2");
348                         da.InsertCommand = null;
349                         Assert.IsNull (da.InsertCommand, "#3");
350                 }
351
352                 [Test]
353                 public void InsertCommand_IDbDataAdapter ()
354                 {
355                         IDbDataAdapter da = new OdbcDataAdapter ();
356                         OdbcCommand cmd1 = new OdbcCommand ();
357                         OdbcCommand cmd2 = new OdbcCommand ();
358
359                         da.InsertCommand = cmd1;
360                         Assert.AreSame (cmd1, da.InsertCommand, "#A1");
361                         da.InsertCommand = cmd2;
362                         Assert.AreSame (cmd2, da.InsertCommand, "#A2");
363                         da.InsertCommand = null;
364                         Assert.IsNull (da.InsertCommand, "#A3");
365
366                         try {
367                                 da.InsertCommand = new OleDbCommand ();
368                                 Assert.Fail ("#B1");
369                         } catch (InvalidCastException ex) {
370                                 Assert.AreEqual (typeof (InvalidCastException), ex.GetType (), "#B2");
371                                 Assert.IsNull (ex.InnerException, "#B3");
372                                 Assert.IsNotNull (ex.Message, "#B4");
373                         }
374                 }
375
376                 [Test]
377                 public void SelectCommand ()
378                 {
379                         OdbcDataAdapter da = new OdbcDataAdapter ();
380                         OdbcCommand cmd1 = new OdbcCommand ();
381                         OdbcCommand cmd2 = new OdbcCommand ();
382
383                         da.SelectCommand = cmd1;
384                         Assert.AreSame (cmd1, da.SelectCommand, "#1");
385                         da.SelectCommand = cmd2;
386                         Assert.AreSame (cmd2, da.SelectCommand, "#2");
387                         da.SelectCommand = null;
388                         Assert.IsNull (da.SelectCommand, "#3");
389                 }
390
391                 [Test]
392                 public void SelectCommand_IDbDataAdapter ()
393                 {
394                         IDbDataAdapter da = new OdbcDataAdapter ();
395                         OdbcCommand cmd1 = new OdbcCommand ();
396                         OdbcCommand cmd2 = new OdbcCommand ();
397
398                         da.SelectCommand = cmd1;
399                         Assert.AreSame (cmd1, da.SelectCommand, "#A1");
400                         da.SelectCommand = cmd2;
401                         Assert.AreSame (cmd2, da.SelectCommand, "#A2");
402                         da.SelectCommand = null;
403                         Assert.IsNull (da.SelectCommand, "#A3");
404
405                         try {
406                                 da.SelectCommand = new OleDbCommand ();
407                                 Assert.Fail ("#B1");
408                         } catch (InvalidCastException ex) {
409                                 Assert.AreEqual (typeof (InvalidCastException), ex.GetType (), "#B2");
410                                 Assert.IsNull (ex.InnerException, "#B3");
411                                 Assert.IsNotNull (ex.Message, "#B4");
412                         }
413                 }
414
415                 [Test]
416                 public void UpdateBatchSize ()
417                 {
418                         OdbcDataAdapter da = new OdbcDataAdapter ();
419                         da.UpdateBatchSize = 1;
420                         Assert.AreEqual (1, da.UpdateBatchSize, "#A");
421
422                         try {
423                                 da.UpdateBatchSize = -2;
424                                 Assert.Fail ("#B1");
425                         } catch (NotSupportedException ex) {
426                                 // Specified method is not supported
427                                 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#B2");
428                                 Assert.IsNull (ex.InnerException, "#B3");
429                                 Assert.IsNotNull (ex.Message, "#B4");
430                         }
431
432                         try {
433                                 da.UpdateBatchSize = 0;
434                                 Assert.Fail ("#C1");
435                         } catch (NotSupportedException ex) {
436                                 // Specified method is not supported
437                                 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#C2");
438                                 Assert.IsNull (ex.InnerException, "#C3");
439                                 Assert.IsNotNull (ex.Message, "#C4");
440                         }
441
442                         try {
443                                 da.UpdateBatchSize = -1;
444                                 Assert.Fail ("#D1");
445                         } catch (NotSupportedException ex) {
446                                 // Specified method is not supported
447                                 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#D2");
448                                 Assert.IsNull (ex.InnerException, "#D3");
449                                 Assert.IsNotNull (ex.Message, "#D4");
450                         }
451                 }
452
453                 [Test]
454                 public void UpdateCommand ()
455                 {
456                         OdbcDataAdapter da = new OdbcDataAdapter ();
457                         OdbcCommand cmd1 = new OdbcCommand ();
458                         OdbcCommand cmd2 = new OdbcCommand ();
459
460                         da.UpdateCommand = cmd1;
461                         Assert.AreSame (cmd1, da.UpdateCommand, "#1");
462                         da.UpdateCommand = cmd2;
463                         Assert.AreSame (cmd2, da.UpdateCommand, "#2");
464                         da.UpdateCommand = null;
465                         Assert.IsNull (da.UpdateCommand, "#3");
466                 }
467
468                 [Test]
469                 public void UpdateCommand_IDbDataAdapter ()
470                 {
471                         IDbDataAdapter da = new OdbcDataAdapter ();
472                         OdbcCommand cmd1 = new OdbcCommand ();
473                         OdbcCommand cmd2 = new OdbcCommand ();
474
475                         da.UpdateCommand = cmd1;
476                         Assert.AreSame (cmd1, da.UpdateCommand, "#A1");
477                         da.UpdateCommand = cmd2;
478                         Assert.AreSame (cmd2, da.UpdateCommand, "#A2");
479                         da.UpdateCommand = null;
480                         Assert.IsNull (da.UpdateCommand, "#A3");
481
482                         try {
483                                 da.UpdateCommand = new OleDbCommand ();
484                                 Assert.Fail ("#B1");
485                         } catch (InvalidCastException ex) {
486                                 Assert.AreEqual (typeof (InvalidCastException), ex.GetType (), "#B2");
487                                 Assert.IsNull (ex.InnerException, "#B3");
488                                 Assert.IsNotNull (ex.Message, "#B4");
489                         }
490                 }
491         }
492 }
493
494 #endif