[Test] public void WriteTest1() { 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] public void WriteTest2() { byte[] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 }; byte[] b2 = new byte[10]; SqlBytes bytes = new SqlBytes(b2); try { bytes.Write(-1, b1, 0, (int)b1.Length); Assert.Fail("#2 Should throw ArgumentOutOfRangeException"); } catch (Exception e) { Assert.AreEqual(typeof(ArgumentOutOfRangeException), e.GetType(), "#2 Should throw ArgumentOutOfRangeException"); } } [Test] public void WriteTest3() { byte[] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 }; byte[] b2 = new byte[10]; SqlBytes bytes = new SqlBytes(b2); try { bytes.Write(0, b1, -1, (int)b1.Length); Assert.Fail("#2 Should throw ArgumentOutOfRangeException"); } catch (Exception e) { Assert.AreEqual(typeof(ArgumentOutOfRangeException), e.GetType(), "#2 Should throw ArgumentOutOfRangeException"); } } [Test] public void WriteTest4() { byte[] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 }; byte[] b2 = new byte[10]; SqlBytes bytes = new SqlBytes(b2); try { bytes.Write(0, b1, 0, (int)b1.Length+5); Assert.Fail("#2 Should throw ArgumentOutOfRangeException"); } catch (Exception e) { Assert.AreEqual(typeof(ArgumentOutOfRangeException), e.GetType(), "#2 Should throw ArgumentOutOfRangeException"); } } [Test] public void WriteTest5() { byte[] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 }; byte[] b2 = new byte[10]; SqlBytes bytes = new SqlBytes(b2); try { bytes.Write(8, b1, 0, (int)b1.Length); Assert.Fail("#2 Should throw SqlTypeException"); } catch (Exception e) { Assert.AreEqual(typeof(SqlTypeException), e.GetType(), "#2 Should throw SqlTypeException"); } } [Test] public void WriteTest6() { byte[] b1 = null; byte[] b2 = new byte[10]; SqlBytes bytes = new SqlBytes(b2); try { bytes.Write(0, b1, 0, 10); Assert.Fail("#2 Should throw ArgumentNullException"); } catch (Exception e) { Assert.AreEqual(typeof(ArgumentNullException), e.GetType(), "#2 Should throw ArgumentNullException"); } } [Test] public void WriteTest7() { byte[] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 }; byte[] b2 = new byte[10]; SqlBytes bytes = new SqlBytes(); try { bytes.Write(0, b1, 0, 10); Assert.Fail("#2 Should throw SqlTypeException"); } catch (Exception e) { Assert.AreEqual(typeof(SqlTypeException), e.GetType(), "#2 Should throw SqlTypeException"); } } [Test] public void WriteTest8() { 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], "#8 Should be same"); Assert.AreEqual(bytes.Value[17], b1[9], "#8 Should be same"); }