public void ThrowsFileNotFoundExceptionWhenFileIsAlreadyDeleted()
            {
                var file = new PlatformFile(this.platformFile);

                FileSystemTest.DeletePlatformItem(this.platformFile);

                string newName = GetUniqueFileName();

                AssertEx.Throws <FileNotFoundException>(() => file.Rename(newName));
            }
            public void UpdatesNamePropertyToReflectChange()
            {
                var file = new PlatformFile(this.platformFile);

                string newName = GetUniqueFileName();

                file.Rename(newName);

                Assert.AreEqual(newName, file.Name);
            }
            public void ThrowsIOExceptionWhenFileWithDesiredNameAlreadyExists()
            {
                var file = new PlatformFile(this.platformFile);

                string newName         = GetUniqueFileName();
                var    conflictingFile = FileSystemTest.CreatePlatformFile(newName);

                AssertEx.Throws <IOException>(() => file.Rename(newName));

                FileSystemTest.DeletePlatformItem(conflictingFile);
            }
            public void RenamesFileInFileSystem()
            {
                var    file    = new PlatformFile(this.platformFile);
                string oldName = GetPlatformFileName(this.platformFile);
                string newName = Guid.NewGuid().ToString("N");

                file.Rename(newName);

                AssertEx.Throws <FileNotFoundException>(() => FileSystemTest.GetPlatformFile(oldName));
                Assert.IsNotNull(FileSystemTest.GetPlatformFile(newName));
            }
            public void ThrowsIOExceptionWhenDesiredFileNameIsTooLong()
            {
                bool expectedException = false;

                try
                {
                    var file = new PlatformFile(this.platformFile);
                    file.Rename(new string('F', 1024));
                }
                catch (PathTooLongException)
                {
                    expectedException = true;
                }
                catch (IOException)
                {
                    // NET CORE 3.0 changed the exception that can be thrown.
                    expectedException = true;
                }

                Assert.IsTrue(expectedException);
            }
            public void ThrowsArgumentExceptionWhenDesiredFileNameIsEmpty()
            {
                var file = new PlatformFile(this.platformFile);

                AssertEx.Throws <ArgumentException>(() => file.Rename(string.Empty));
            }
Ejemplo n.º 7
0
            public void ThrowsIOExceptionWhenDesiredFileNameIsTooLong()
            {
                var file = new PlatformFile(this.platformFile);

                AssertEx.Throws <PathTooLongException>(() => file.Rename(new string('F', 1024)));
            }
            public void ThrowsArgumentNullExceptionWhenDesiredNameIsNull()
            {
                var file = new PlatformFile(this.platformFile);

                AssertEx.Throws <ArgumentNullException>(() => file.Rename(null));
            }
 public void ThrowsIOExceptionWhenDesiredFileNameIsTooLong()
 {
     var file = new PlatformFile(this.platformFile);
     Assert.Throws<PathTooLongException>(() => file.Rename(new string('F', 1024)));
 }
 public void ThrowsArgumentExceptionWhenDesiredFileNameIsEmpty()
 {
     var file = new PlatformFile(this.platformFile);
     Assert.Throws<ArgumentException>(() => file.Rename(string.Empty));
 }
            public void ThrowsIOExceptionWhenFileWithDesiredNameAlreadyExists()
            {
                var file = new PlatformFile(this.platformFile);

                string newName = GetUniqueFileName();
                var conflictingFile = FileSystemTest.CreatePlatformFile(newName);

                Assert.Throws<IOException>(() => file.Rename(newName));

                FileSystemTest.DeletePlatformItem(conflictingFile);
            }
            public void ThrowsFileNotFoundExceptionWhenFileIsAlreadyDeleted()
            {
                var file = new PlatformFile(this.platformFile);

                FileSystemTest.DeletePlatformItem(this.platformFile);

                string newName = GetUniqueFileName();
                Assert.Throws<FileNotFoundException>(() => file.Rename(newName));
            }
            public void UpdatesNamePropertyToReflectChange()
            {
                var file = new PlatformFile(this.platformFile);

                string newName = GetUniqueFileName();
                file.Rename(newName);

                Assert.Equal(newName, file.Name);
            }
            public void RenamesFileInFileSystem()
            {
                var file = new PlatformFile(this.platformFile);
                string oldName = GetPlatformFileName(this.platformFile);
                string newName = Guid.NewGuid().ToString("N");

                file.Rename(newName);

                Assert.Throws<FileNotFoundException>(() => FileSystemTest.GetPlatformFile(oldName));
                Assert.NotNull(FileSystemTest.GetPlatformFile(newName));
            }
 public void ThrowsArgumentNullExceptionWhenDesiredNameIsNull()
 {
     var file = new PlatformFile(this.platformFile);
     Assert.Throws<ArgumentNullException>(() => file.Rename(null));
 }