Exemplo n.º 1
0
        public void DisposingCanBeCalledTwise()
        {
            var fileWriter = new Convestudo.Unmanaged.FileWriter(TestFileName);

            fileWriter.Dispose();
            Assert.DoesNotThrow(fileWriter.Dispose);
        }
Exemplo n.º 2
0
        public void ResourceIsLocked()
        {
            using (var fileWriter1 = new Convestudo.Unmanaged.FileWriter(TestFileName))
            {
                fileWriter1.Write("Test");

                Assert.Throws <FileLoadException>(() =>
                {
                    using (var file2 = new Convestudo.Unmanaged.FileWriter(TestFileName))
                        file2.Write("adsf");
                });
            }
        }
Exemplo n.º 3
0
        public void WriteLineWritesWithNewLine()
        {
            const string testLine    = "TestLine";
            var          extectedStr = String.Format("{0}{1}{0}{1}{0}{1}{0}{1}", testLine, Environment.NewLine);

            using (var fileWriter = new Convestudo.Unmanaged.FileWriter(TestFileName))
            {
                fileWriter.WriteLine(testLine);
                fileWriter.WriteLine(testLine);
                fileWriter.WriteLine(testLine);
                fileWriter.WriteLine(testLine);
            }

            using (var streamReader = new StreamReader(TestFileName))
            {
                var str = streamReader.ReadToEnd();
                Assert.AreEqual(extectedStr, str);
            }
        }
Exemplo n.º 4
0
        public void WriteFewWordsDoesWork()
        {
            const string testLine    = "TestLine";
            var          extectedStr = String.Format("{0}{0}{0}{0}", testLine);

            using (var fileWriter = new Convestudo.Unmanaged.FileWriter(TestFileName))
            {
                fileWriter.Write(testLine);
                fileWriter.Write(testLine);
                fileWriter.Write(testLine);
                fileWriter.Write(testLine);
            }

            using (var streamReader = new StreamReader(TestFileName))
            {
                var str = streamReader.ReadToEnd();
                Assert.AreEqual(extectedStr, str);
            }
        }
Exemplo n.º 5
0
        public void DisposeDoesWork()
        {
            var fileWriter = new Convestudo.Unmanaged.FileWriter(TestFileName);

            Assert.DoesNotThrow(fileWriter.Dispose);
        }