public void NoSeekTest() { byte[] buf = new byte[50]; Random rnd = new Random(); for (int i = 0; i < 50; i++) { buf [i] = (byte)rnd.Next(); } Stream noSeekStream = new NoSeekMemoryStream(buf); Assert.AreEqual(false, noSeekStream.CanSeek); try { noSeekStream.Seek(10, SeekOrigin.Current); throw new InvalidOperationException("This should not happen"); } catch (NotSupportedException) { // should catch the execption } //Cannot set position Assert.Throws <NotImplementedException> (delegate { noSeekStream.Position = 10; }); }
public void NetworkStream_OnSeek_ExceptionThrown() { byte[] bytes = System.Text.Encoding.Unicode.GetBytes(TEST_STRING); NoSeekMemoryStream stream = new NoSeekMemoryStream(bytes, 10, 5); stream.Seek(12, System.IO.SeekOrigin.Begin); }
public void SeekMethodExceptionTest() { NoSeekMemoryStream ms = new NoSeekMemoryStream(new byte[1]); try{ ms.Seek(5, SeekOrigin.Begin); Assert.Fail(); } catch (NotSupportedException) { } }
public void TestMethod8() { try { byte[] buf1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; NoSeekMemoryStream nsms = new NoSeekMemoryStream(buf1); nsms.Seek(2, SeekOrigin.Current); Assert.Fail("An exception should have been thrown"); } catch (Exception e) { Assert.AreEqual(e.GetType(), typeof(NotSupportedException)); } }
static public bool SeekTests() { Console.WriteLine("\nTesting Seek Functionality: "); byte[] b = new byte[80000]; NoSeekMemoryStream ns = new NoSeekMemoryStream(b); Console.Write("\tTesting CanSeek, false expected: "); if (ns.CanSeek) { Console.WriteLine("FAILED"); } else { Console.WriteLine("SUCCESS"); } try { Console.Write("\tTesting Seeking function, exception expected: "); ns.Seek(10, System.IO.SeekOrigin.Begin); Console.WriteLine("FAILED"); } catch { Console.WriteLine("SUCCESS"); } /* * try * { * Console.Write("\tTesting setting position, exception expected: "); * ns.Position = 12; * Console.WriteLine("FAILED"); * } * catch * { * Console.WriteLine("SUCCESS"); * } */ return(true); }
public void SeekMethodTest() { NoSeekMemoryStream stream = new NoSeekMemoryStream(new byte[1024]); Assert.Throws <NotSupportedException>(() => stream.Seek(0, System.IO.SeekOrigin.Begin)); }
public void seekEnd() { NoSeekMemoryStream nsms = new NoSeekMemoryStream(string1, 0, 2); Assert.Throws <NotSupportedException>(() => nsms.Seek(2, SeekOrigin.End)); }
public void seekTest1() { NoSeekMemoryStream ms1 = new NoSeekMemoryStream(string1); Assert.Throws <NotSupportedException>(() => ms1.Seek(0, SeekOrigin.Begin)); }