Exemplo n.º 1
0
        public void TestRandomWriteBeginning()
        {
            var filename = RandomFilename();
            try
            {
                if (File.Exists(filename)) File.Delete(filename);
                Assert.IsFalse(File.Exists(filename));

                using (var w = new Writer(filename))
                {
                    w.WriteFile(Small, 0);
                }

                Assert.IsTrue(File.Exists(filename), String.Format("File {0} should exist", filename));
                Assert.IsTrue(File.ReadAllText(filename).StartsWith("1234"));
            }
            finally
            {
                File.Delete(filename);
            }
        }
Exemplo n.º 2
0
        public void TestSmallerBigFile()
        {
            var filename = RandomFilename();

            try
            {
                if (File.Exists(filename)) File.Delete(filename);
                Assert.IsFalse(File.Exists(filename));

                using (var w = new Writer(filename))
                {
                    w.WriteFile(Same, 0); // this should just work
                }

                Assert.IsTrue(File.Exists(filename), String.Format("File {0} should exist", filename));
            }
            finally
            {
                File.Delete(filename);
            }
        }
Exemplo n.º 3
0
        public void TestTooBigFile()
        {
            var filename = RandomFilename();
            try
            {
                if (File.Exists(filename)) File.Delete(filename);
                Assert.IsFalse(File.Exists(filename));

                using (var w = new Writer(filename))
                {
                    w.WriteFile(Bigger, 0); // this should throw an exception!
                }
            }
            finally
            {
                File.Delete(filename);
            }
        }
Exemplo n.º 4
0
        public void TestSmallerBigFileFail()
        {
            var filename = RandomFilename();
            try
            {
                if (File.Exists(filename)) File.Delete(filename);
                Assert.IsFalse(File.Exists(filename));

                using (var w = new Writer(filename))
                {
                    w.WriteFile(Same, 1); // one byte overflow => this should throw an exception!
                }

                Assert.IsTrue(File.Exists(filename), String.Format("File {0} should exist", filename));
            }
            finally
            {
                File.Delete(filename);
            }
        }