Ejemplo n.º 1
0
        public void Test_CreateFileObject_HaveAPathTYpeOfFile_WhenFIleExist()
        {
            var testFile = RandomTestFileNoExtension;


            var filePath = testFile.FilePathOnly + "AnotherTest.Gohan";

            using (var file = new DotNetHelper_IO.FileObject(filePath))
            {
                file.CreateOrTruncate();
                Assert.AreEqual(file.PathType, PathType.File);
            }
        }
Ejemplo n.º 2
0
        public async Task Test_Copy_To_File_IncrementFileName_WhenFileNameEndsWithNumber()
        {
            var testFile   = RandomTestFileNoExtension;
            var outputFile = new DotNetHelper_IO.FileObject(RandomTestFileNoExtension.FullName + "1");

            await testFile.WriteAsync("ABC");

            outputFile.CreateOrTruncate();

            var newFileName = await testFile.CopyToAsync(outputFile.FullName, FileOption.IncrementFileNameIfExist);

            Assert.That(!newFileName.Equals(testFile.FullName + "1"));
            Assert.That((await File.ReadAllTextAsync(newFileName)).Equals("ABC"));
        }
Ejemplo n.º 3
0
        public void Test_Change_Extension_With_File_Having_A_Extension()
        {
            var testFile = RandomTestFileNoExtension;


            var filePath = testFile.FilePathOnly + "AnotherTest.Gohan";

            using (var file = new DotNetHelper_IO.FileObject(filePath))
            {
                file.CreateOrTruncate();
                file.ChangeExtension(".Vegeta", FileOption.Overwrite);
                FileShouldExist($"{file.FilePathOnly}{file.FileNameOnlyNoExtension}.Vegeta");
                FileShouldNotExist(filePath);
                Assert.Pass("Successfully change extension of file");
            }
        }