DbDataAdapterTest.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. //
  2. // DbDataAdapterTest.cs - NUnit Test Cases for testing the DbDataAdapter class
  3. //
  4. // Author:
  5. // Gert Driesen ([email protected])
  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. using System;
  29. using System.Data;
  30. using System.Data.Common;
  31. using NUnit.Framework;
  32. namespace MonoTests.System.Data.Common
  33. {
  34. [TestFixture]
  35. public class DbDataAdapterTest
  36. {
  37. #if NET_2_0
  38. [Test]
  39. public void UpdateBatchSize ()
  40. {
  41. MyAdapter da = new MyAdapter ();
  42. try {
  43. da.UpdateBatchSize = 0;
  44. Assert.Fail ("#A1");
  45. } catch (NotSupportedException ex) {
  46. // Specified method is not supported
  47. Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#A2");
  48. Assert.IsNull (ex.InnerException, "#A3");
  49. Assert.IsNotNull (ex.Message, "#A4");
  50. }
  51. Assert.AreEqual (1, da.UpdateBatchSize, "#A5");
  52. try {
  53. da.UpdateBatchSize = int.MaxValue;
  54. Assert.Fail ("#B1");
  55. } catch (NotSupportedException ex) {
  56. // Specified method is not supported
  57. Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#B2");
  58. Assert.IsNull (ex.InnerException, "#B3");
  59. Assert.IsNotNull (ex.Message, "#B4");
  60. }
  61. Assert.AreEqual (1, da.UpdateBatchSize, "#B5");
  62. da.UpdateBatchSize = 1;
  63. Assert.AreEqual (1, da.UpdateBatchSize, "#C");
  64. }
  65. [Test]
  66. public void UpdateBatchSize_Negative ()
  67. {
  68. MyAdapter da = new MyAdapter ();
  69. try {
  70. da.UpdateBatchSize = -1;
  71. Assert.Fail ("#1");
  72. } catch (NotSupportedException ex) {
  73. // Specified method is not supported
  74. Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
  75. Assert.IsNull (ex.InnerException, "#3");
  76. Assert.IsNotNull (ex.Message, "#4");
  77. }
  78. }
  79. #endif
  80. class MyAdapter : DbDataAdapter
  81. {
  82. #if ONLY_1_1
  83. protected override RowUpdatedEventArgs CreateRowUpdatedEvent (DataRow dataRow, IDbCommand command,
  84. StatementType statementType,
  85. DataTableMapping tableMapping)
  86. {
  87. throw new NotImplementedException ();
  88. }
  89. protected override RowUpdatingEventArgs CreateRowUpdatingEvent (DataRow dataRow, IDbCommand command,
  90. StatementType statementType,
  91. DataTableMapping tableMapping)
  92. {
  93. throw new NotImplementedException ();
  94. }
  95. protected override void OnRowUpdated (RowUpdatedEventArgs value)
  96. {
  97. throw new NotImplementedException ();
  98. }
  99. protected override void OnRowUpdating (RowUpdatingEventArgs value)
  100. {
  101. throw new NotImplementedException ();
  102. }
  103. #endif
  104. }
  105. }
  106. }