New tests for Read and Write APIs.
authorVeerapuram Varadhan <v.varadhan@gmail.com>
Mon, 1 Oct 2007 18:43:20 +0000 (18:43 -0000)
committerVeerapuram Varadhan <v.varadhan@gmail.com>
Mon, 1 Oct 2007 18:43:20 +0000 (18:43 -0000)
svn path=/trunk/mcs/; revision=86720

mcs/class/System.Data/Test/System.Data.SqlTypes/ChangeLog
mcs/class/System.Data/Test/System.Data.SqlTypes/SqlBytesTest.cs
mcs/class/System.Data/Test/System.Data.SqlTypes/SqlCharsTest.cs

index 66b9b8e0c0afdf9f7d3b42c131808762baf37bf7..9062417ceb8813bd4f69272abda0a0c41d9f80bb 100644 (file)
@@ -1,3 +1,10 @@
+2007-10-01  Veerapuram Varadhan  <vvaradhan@novell.com>
+
+       * SqlCharsTest.cs (Read_*, Write_*): Tests for Newly implemented
+       Read and Write APIs.
+
+       * SqlBytesTest.cs (Read_*, Write_*): Ditto.
+       
 2007-09-27  Veerapuram Varadhan  <vvaradhan@novell.com>
 
        * SqlStringTest.cs (ReadWriteXmlTest): Change the root node of the
index 5754b8c1205488436da0ffca47e71774e396bc16..86bb31d271e0bf4f1ab8e580cb67558ea98e9878 100644 (file)
@@ -214,6 +214,278 @@ namespace MonoTests.System.Data.SqlTypes
                        XmlQualifiedName qualifiedName = SqlBytes.GetXsdType (null);
                        NUnit.Framework.Assert.AreEqual ("base64Binary", qualifiedName.Name, "#A01");
                }
+
+               /* Read tests */
+               [Test]
+               public void Read_SuccessTest1 ()
+               {
+                       byte [] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 };
+                       SqlBytes bytes = new SqlBytes (b1);
+                       byte [] b2 = new byte [10];
+
+                       bytes.Read (0, b2, 0, (int) bytes.Length);
+                       Assert.AreEqual (bytes.Value [5], b2 [5], "#1 Should be equal");
+               }
+               
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void Read_NullBufferTest ()
+               {                       
+                       byte [] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 };
+                       SqlBytes bytes = new SqlBytes (b1);                     
+                       byte [] b2 = null;
+                       
+                       bytes.Read (0, b2, 0, 10);
+                       Assert.Fail ("#2 Should throw ArgumentNullException");
+               }
+               
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void Read_InvalidCountTest1 ()
+               {                       
+                       byte [] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 };
+                       SqlBytes bytes = new SqlBytes (b1);                     
+                       byte [] b2 = new byte [5]; 
+                       
+                       bytes.Read (0, b2, 0, 10);
+                       Assert.Fail ("#3 Should throw ArgumentOutOfRangeException");
+               }
+               
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void Read_NegativeOffsetTest ()
+               {                       
+                       byte [] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 };
+                       SqlBytes bytes = new SqlBytes (b1);                     
+                       byte [] b2 = new byte [5];
+                       
+                       bytes.Read (-1, b2, 0, 4);
+                       Assert.Fail ("#4 Should throw ArgumentOutOfRangeException");
+               }
+               
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void Read_NegativeOffsetInBufferTest ()
+               {                       
+                       byte [] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 };
+                       SqlBytes bytes = new SqlBytes (b1);                     
+                       byte [] b2 = new byte [5];
+                       
+                       bytes.Read (0, b2, -1, 4);
+                       Assert.Fail ("#5 Should throw ArgumentOutOfRangeException");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void Read_InvalidOffsetInBufferTest ()
+               {                       
+                       byte [] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 };
+                       SqlBytes bytes = new SqlBytes (b1);                     
+                       byte [] b2 = new byte [5];
+                       
+                       bytes.Read (0, b2, 8, 4);
+                       Assert.Fail ("#6 Should throw ArgumentOutOfRangeException");
+               }
+               
+               [Test]
+               [ExpectedException (typeof (SqlNullValueException))]
+               public void Read_NullInstanceValueTest ()
+               {                       
+                       byte [] b2 = new byte [5];
+                       SqlBytes bytes = new SqlBytes ();
+                       
+                       bytes.Read (0, b2, 8, 4);
+                       Assert.Fail ("#7 Should throw SqlNullValueException");
+               }
+               
+               [Test]
+               public void Read_SuccessTest2 ()
+               {
+                       byte [] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 };                        
+                       SqlBytes bytes = new SqlBytes (b1);
+                       byte [] b2 = new byte [10];
+                       
+                       bytes.Read (5, b2, 0, 10);
+                       Assert.AreEqual (bytes.Value [5], b2 [0], "#8 Should be same");
+                       Assert.AreEqual (bytes.Value [9], b2 [4], "#9 Should be same");
+               }
+               
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void Read_NullBufferAndInstanceValueTest ()
+               {                       
+                       byte [] b2 = null;
+                       SqlBytes bytes = new SqlBytes ();
+                       
+                       bytes.Read (0, b2, 8, 4);
+                       Assert.Fail ("#10 Should throw ArgumentNullException");
+               }
+               
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void Read_NegativeCountTest ()
+               {                       
+                       byte [] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 };
+                       SqlBytes bytes = new SqlBytes (b1);                     
+                       byte [] b2 = new byte [5];
+                       
+                       bytes.Read (0, b2, 0, -1);
+                       Assert.Fail ("#11 Should throw ArgumentOutOfRangeException");
+               }
+               
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void Read_InvalidCountTest2 ()
+               {                       
+                       byte [] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 };
+                       SqlBytes bytes = new SqlBytes (b1);                     
+                       byte [] b2 = new byte [5]; 
+                       
+                       bytes.Read (0, b2, 3, 4);
+                       Assert.Fail ("#12 Should throw ArgumentOutOfRangeException");
+               }
+               
+               /* Write Tests */
+               [Test]
+               public void Write_SuccessTest1 ()
+               {
+                       byte [] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 };
+                       byte [] b2 = new byte[10];
+                       SqlBytes bytes = new SqlBytes (b2);
+                       
+                       bytes.Write (0, b1, 0, (int) b1.Length);
+                       Assert.AreEqual (bytes.Value [0], b1 [0], "#1 Should be same");
+               }
+               
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void Write_NegativeOffsetTest ()
+               {
+                       byte [] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 };
+                       byte [] b2 = new byte [10];
+                       SqlBytes bytes = new SqlBytes (b2);
+                       
+                       bytes.Write (-1, b1, 0, (int) b1.Length);
+                       Assert.Fail ("#2 Should throw ArgumentOutOfRangeException");
+               }
+               
+               [Test]
+               [ExpectedException (typeof (SqlTypeException))]
+               public void Write_InvalidOffsetTest ()
+               {
+                       byte [] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 };
+                       byte [] b2 = new byte [10];
+                       SqlBytes bytes = new SqlBytes (b2);
+                       
+                       bytes.Write (bytes.Length+5, b1, 0, (int) b1.Length);
+                       Assert.Fail ("#3 Should throw SqlTypeException");
+               }
+               
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void Write_NegativeOffsetInBufferTest ()
+               {
+                       byte [] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 };
+                       byte [] b2 = new byte [10];
+                       SqlBytes bytes = new SqlBytes (b2);
+                       
+                       bytes.Write (0, b1, -1, (int) b1.Length);
+                       Assert.Fail ("#4 Should throw ArgumentOutOfRangeException");
+               }
+               
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void Write_InvalidOffsetInBufferTest ()
+               {
+                       byte [] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 };
+                       byte [] b2 = new byte [10];
+                       SqlBytes bytes = new SqlBytes (b2);
+                       
+                       bytes.Write (0, b1, b1.Length+5, (int) b1.Length);
+                       Assert.Fail ("#5 Should throw ArgumentOutOfRangeException");
+               }
+               
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void Write_InvalidCountTest1 ()
+               {
+                       byte [] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 };
+                       byte [] b2 = new byte [10];
+                       SqlBytes bytes = new SqlBytes (b2);
+                       
+                       bytes.Write (0, b1, 0, (int) b1.Length+5);
+                       Assert.Fail ("#6 Should throw ArgumentOutOfRangeException");
+               }
+               
+               [Test]
+               [ExpectedException (typeof (SqlTypeException))]
+               public void Write_InvalidCountTest2 ()
+               {
+                       byte [] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 };
+                       byte [] b2 = new byte [10];
+                       SqlBytes bytes = new SqlBytes (b2);
+                       
+                       bytes.Write (8, b1, 0, (int) b1.Length);
+                       Assert.Fail ("#7 Should throw SqlTypeException");
+               }
+               
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void Write_NullBufferTest ()
+               {
+                       byte [] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 };
+                       byte [] b2 = null;
+                       SqlBytes bytes = new SqlBytes (b1);
+                       
+                       bytes.Write (0, b2, 0, 10);
+                       Assert.Fail ("#8 Should throw ArgumentNullException");
+               }
+               
+               [Test]
+               [ExpectedException (typeof (SqlTypeException))]
+               public void Write_NullInstanceValueTest ()
+               {
+                       byte [] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 };
+                       SqlBytes bytes = new SqlBytes();
+                       
+                       bytes.Write (0, b1, 0, 10);
+                       Assert.Fail ("#9 Should throw SqlTypeException");
+               }
+               
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void Write_NullBufferAndInstanceValueTest ()
+               {
+                       byte [] b1 = null;
+                       SqlBytes bytes = new SqlBytes();
+                       
+                       bytes.Write (0, b1, 0, 10);
+                       Assert.Fail ("#9 Should throw ArgumentNullException");
+               }
+               
+               [Test]
+               public void Write_SuccessTest2 ()
+               {
+                       byte [] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 };
+                       byte [] b2 = new byte [20];
+                       SqlBytes bytes = new SqlBytes (b2);
+                       
+                       bytes.Write (8, b1, 0, 10);
+                       Assert.AreEqual (bytes.Value [8], b1 [0], "#10 Should be same");
+                       Assert.AreEqual (bytes.Value [17], b1 [9], "#10 Should be same");
+               }
+               
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void Write_NegativeCountTest ()
+               {
+                       byte [] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 };
+                       byte [] b2 = new byte [10];
+                       SqlBytes bytes = new SqlBytes (b2);
+                       
+                       bytes.Write (0, b1, 0, -1);
+                       Assert.Fail ("#11 Should throw ArgumentOutOfRangeException");
+               }
        }
 }
 #endif
index fe309206af3faaac68e9e58de7703b2a26682c5c..7df8c6edefed4b1a5a46a3bd459bb1aff574e971 100644 (file)
@@ -39,7 +39,6 @@ using System.Globalization;
 
 #if NET_2_0
 using System.Xml.Serialization;
-using System.IO;
 #endif 
 
 namespace MonoTests.System.Data.SqlTypes
@@ -254,6 +253,277 @@ namespace MonoTests.System.Data.SqlTypes
                        ReadWriteXmlTestInternal (xml1, strtest1, "BA01");
                        ReadWriteXmlTestInternal (xml2, strtest2.ToString (), "BA02");
                }
+
+               /* Read tests */
+               [Test]
+               public void Read_SuccessTest1 ()
+               {
+                       char [] c1 = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' };
+                       SqlChars chars = new SqlChars (c1);
+                       char [] c2 = new char [10];
+
+                       chars.Read (0, c2, 0, (int) chars.Length);
+                       Assert.AreEqual (chars.Value [5], c2 [5], "#1 Should be equal");
+               }
+               
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void Read_NullBufferTest ()
+               {                       
+                       char [] c1 = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' };
+                       SqlChars chars = new SqlChars (c1);                     
+                       char [] c2 = null;
+                       
+                       chars.Read (0, c2, 0, 10);
+                       Assert.Fail ("#2 Should throw ArgumentNullException");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void Read_InvalidCountTest1 ()
+               {                       
+                       char [] c1 = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' };
+                       SqlChars chars = new SqlChars (c1);                     
+                       char [] c2 = new char [5]; 
+
+                       chars.Read (0, c2, 0, 10);
+                       Assert.Fail ("#3 Should throw ArgumentOutOfRangeException");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void Read_NegativeOffsetTest ()
+               {                       
+                       char [] c1 = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' };
+                       SqlChars chars = new SqlChars (c1);                     
+                       char [] c2 = new char [5];
+                       
+                       chars.Read (-1, c2, 0, 4);
+                       Assert.Fail ("#4 Should throw ArgumentOutOfRangeException");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void Read_NegativeOffsetInBufferTest ()
+               {                       
+                       char [] c1 = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' };
+                       SqlChars chars = new SqlChars (c1);                     
+                       char [] c2 = new char [5];
+                       
+                       chars.Read (0, c2, -1, 4);
+                       Assert.Fail ("#5 Should throw ArgumentOutOfRangeException");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void Read_InvalidOffsetInBufferTest ()
+               {                       
+                       char [] c1 = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' };
+                       SqlChars chars = new SqlChars (c1);                     
+                       char [] c2 = new char [5];
+                       
+                       chars.Read (0, c2, 8, 4);
+                       Assert.Fail ("#6 Should throw ArgumentOutOfRangeException");
+               }
+
+               [Test]
+               [ExpectedException (typeof (SqlNullValueException))]
+               public void Read_NullInstanceValueTest ()
+               {                       
+                       char [] c2 = new char [5];
+                       SqlChars chars = new SqlChars ();
+                       
+                       chars.Read (0, c2, 8, 4);
+                       Assert.Fail ("#7 Should throw SqlNullValueException");
+               }
+
+               [Test]
+               public void Read_SuccessTest2 ()
+               {
+                       char [] c1 = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' };                      
+                       SqlChars chars = new SqlChars (c1);
+                       char [] c2 = new char [10];
+                       
+                       chars.Read (5, c2, 0, 10);
+                       Assert.AreEqual (chars.Value [5], c2 [0], "#8 Should be same");
+                       Assert.AreEqual (chars.Value [9], c2 [4], "#9 Should be same");
+               }
+               
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void Read_NullBufferAndInstanceValueTest ()
+               {                       
+                       char [] c2 = null;
+                       SqlChars chars = new SqlChars ();
+                       
+                       chars.Read (0, c2, 8, 4);
+                       Assert.Fail ("#10 Should throw ArgumentNullException");
+               }
+               
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void Read_NegativeCountTest ()
+               {                       
+                       char [] c1 = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' };
+                       SqlChars chars = new SqlChars (c1);                     
+                       char [] c2 = new char [5];
+                       
+                       chars.Read (0, c2, 0, -1);
+                       Assert.Fail ("#11 Should throw ArgumentOutOfRangeException");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void Read_InvalidCountTest2 ()
+               {                       
+                       char [] c1 = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' };
+                       SqlChars chars = new SqlChars (c1);                     
+                       char [] c2 = new char [5]; 
+
+                       chars.Read (0, c2, 3, 4);
+                       Assert.Fail ("#12 Should throw ArgumentOutOfRangeException");
+               }
+               
+               [Test]
+               public void Write_SuccessTest1 ()
+               {
+                       char [] c1 = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' };
+                       char [] c2 = new char [10];
+                       SqlChars chars = new SqlChars (c2);
+
+                       chars.Write (0, c1, 0, (int) c1.Length);
+                       Assert.AreEqual (chars.Value [0], c1 [0], "#1 Should be same");
+               }
+               
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void Write_NegativeOffsetTest ()
+               {
+                       char [] c1 = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' };
+                       char [] c2 = new char [10];
+                       SqlChars chars = new SqlChars (c2);
+
+                       chars.Write (-1, c1, 0, (int) c1.Length);
+                       Assert.Fail ("#2 Should throw ArgumentOutOfRangeException");
+               }
+
+               [Test]
+               [ExpectedException (typeof (SqlTypeException))]
+               public void Write_InvalidOffsetTest ()
+               {
+                       char [] c1 = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' };
+                       char [] c2 = new char [10];
+                       SqlChars chars = new SqlChars (c2);
+                       
+                       chars.Write (chars.Length+5, c1, 0, (int) c1.Length);
+                       Assert.Fail ("#3 Should throw SqlTypeException");
+               }
+               
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void Write_NegativeOffsetInBufferTest ()
+               {
+                       char [] c1 = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' };
+                       char [] c2 = new char [10];
+                       SqlChars chars = new SqlChars (c2);
+
+                       chars.Write (0, c1, -1, (int) c1.Length);
+                       Assert.Fail ("#4 Should throw ArgumentOutOfRangeException");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void Write_InvalidOffsetInBufferTest ()
+               {
+                       char [] c1 = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' };
+                       char [] c2 = new char [10];
+                       SqlChars chars = new SqlChars (c2);
+
+                       chars.Write (0, c1, c1.Length+5, (int) c1.Length);
+                       Assert.Fail ("#5 Should throw ArgumentOutOfRangeException");
+               }
+               
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void Write_InvalidCountTest1 ()
+               {
+                       char [] c1 = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' };
+                       char [] c2 = new char [10];
+                       SqlChars chars = new SqlChars (c2);
+
+                       chars.Write (0, c1, 0, (int) c1.Length+5);
+                       Assert.Fail ("#6 Should throw ArgumentOutOfRangeException");
+               }
+
+               [Test]
+               [ExpectedException (typeof (SqlTypeException))]
+               public void Write_InvalidCountTest2 ()
+               {
+                       char [] c1 = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' };
+                       char [] c2 = new char [10];
+                       SqlChars chars = new SqlChars (c2);
+
+                       chars.Write (8, c1, 0, (int) c1.Length);
+                       Assert.Fail ("#7 Should throw SqlTypeException");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void Write_NullBufferTest ()
+               {
+                       char [] c1 = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' };
+                       char [] c2 = null;
+                       SqlChars chars = new SqlChars (c1);
+
+                       chars.Write (0, c2, 0, 10);
+                       Assert.Fail ("#8 Should throw ArgumentNullException");
+               }
+
+               [Test]
+               [ExpectedException (typeof (SqlTypeException))]
+               public void Write_NullInstanceValueTest ()
+               {
+                       char [] c1 = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' };
+                       SqlChars chars = new SqlChars();
+
+                       chars.Write (0, c1, 0, 10);
+                       Assert.Fail ("#9 Should throw SqlTypeException");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void Write_NullBufferAndInstanceValueTest ()
+               {
+                       char [] c1 = null;
+                       SqlChars chars = new SqlChars();
+                       
+                       chars.Write (0, c1, 0, 10);
+                       Assert.Fail ("#9 Should throw ArgumentNullException");
+               }
+               
+               [Test]
+               public void Write_SuccessTest2 ()
+               {
+                       char [] c1 = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' };
+                       char [] c2 = new char [20];
+                       SqlChars chars = new SqlChars (c2);
+
+                       chars.Write (8, c1, 0, 10);
+                       Assert.AreEqual (chars.Value [8], c1 [0], "#10 Should be same");
+                       Assert.AreEqual (chars.Value [17], c1 [9], "#10 Should be same");
+               }
+               
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void Write_NegativeCountTest ()
+               {
+                       char [] c1 = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' };
+                       char [] c2 = new char [10];
+                       SqlChars chars = new SqlChars (c2);
+
+                       chars.Write (0, c1, 0, -1);
+                       Assert.Fail ("#11 Should throw ArgumentOutOfRangeException");
+               }
        }
 }