SetLength() public method

public SetLength ( long value ) : void
value long
return void
Beispiel #1
0
        public override void SetLength(long value)
        {
            CheckIfStreamClosed("SetLength");

            _sqlchars.SetLength(value);
            if (_lPosition > value)
            {
                _lPosition = value;
            }
        }
Beispiel #2
0
		public void SqlCharsSetLength ()
		{
			char [] b1 = new char [10];
			SqlChars chars = new SqlChars ();
			try {
				chars.SetLength (20);
				Assert.Fail ("Should throw SqlTypeException");
			} catch (Exception ex) {
				Assert.AreEqual (typeof (SqlTypeException), ex.GetType (), "Should throw SqlTypeException");
			}
			chars = new SqlChars (b1);
			Assert.AreEqual (chars.Length, 10, "#1 Should be same");
			try {
				chars.SetLength (-1);
				Assert.Fail ("Should throw ArgumentOutOfRangeException");
			} catch (Exception ex) {
				Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "Should throw ArgumentOutOfRangeException");
			}
			try {
				chars.SetLength (11);
				Assert.Fail ("Should throw ArgumentOutOfRangeException");
			} catch (Exception ex) {
				Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "Should throw ArgumentOutOfRangeException");
			}
			chars.SetLength (2);
			Assert.AreEqual (chars.Length, 2, "#2 Should be same");
		}
Beispiel #3
0
 public void SqlCharsSetLength()
 {
     char[] b1 = new char[10];
     SqlChars chars = new SqlChars();
     try
     {
         chars.SetLength(20);
         Assert.False(true);
     }
     catch (Exception ex)
     {
         Assert.Equal(typeof(SqlTypeException), ex.GetType());
     }
     chars = new SqlChars(b1);
     Assert.Equal(chars.Length, 10);
     try
     {
         chars.SetLength(-1);
         Assert.False(true);
     }
     catch (Exception ex)
     {
         Assert.Equal(typeof(ArgumentOutOfRangeException), ex.GetType());
     }
     try
     {
         chars.SetLength(11);
         Assert.False(true);
     }
     catch (Exception ex)
     {
         Assert.Equal(typeof(ArgumentOutOfRangeException), ex.GetType());
     }
     chars.SetLength(2);
     Assert.Equal(chars.Length, 2);
 }