Пример #1
0
        public void TestClose()
        {
#if FALSE
            string path = TempFolder + Path.DirectorySeparatorChar + "TestClose";
            DeleteFile(path);

            StdioFileStream stream = new StdioFileStream(path, FileMode.CreateNew, FileAccess.ReadWrite);

            stream.Write(new byte [] { 1, 2, 3, 4 }, 0, 4);
            stream.ReadByte();
            stream.Close();

            try {
                stream.ReadByte();
                Assert.Fail();
            } catch (Exception e) {
                Assert.AreEqual(typeof(ObjectDisposedException), e.GetType(), "test#01");
            }

            try {
                stream.WriteByte(64);
                Assert.Fail();
            } catch (Exception e) {
                Assert.AreEqual(typeof(ObjectDisposedException), e.GetType(), "test#02");
            }

            try {
                stream.Flush();
                Assert.Fail();
            } catch (Exception e) {
                Assert.AreEqual(typeof(ObjectDisposedException), e.GetType(), "test#03");
            }

            try {
                long l = stream.Length;
                Assert.Fail();
            } catch (Exception e) {
                Assert.AreEqual(typeof(ObjectDisposedException), e.GetType(), "test#04");
            }

            try {
                long l = stream.Position;
                Assert.Fail();
            } catch (Exception e) {
                Assert.AreEqual(typeof(ObjectDisposedException), e.GetType(), "test#05");
            }

            try {
                FilePosition fp = stream.FilePosition;
                fp.Dispose();
                Assert.Fail();
            } catch (Exception e) {
                Assert.AreEqual(typeof(ObjectDisposedException), e.GetType(), "test#05");
            }

            Assert.AreEqual(false, stream.CanRead, "test#06");
            Assert.AreEqual(false, stream.CanSeek, "test#07");
            Assert.AreEqual(false, stream.CanWrite, "test#08");

            DeleteFile(path);
#endif
        }