Example #1
0
        public async Task Refactor_RenameClassNameAndFileName_ShouldNotPromptToReload()
        {
            FilePath directory = UnitTests.Util.CreateTmpDir("FileRenameShouldNotPromptToReload");
            FilePath fileName  = directory.Combine("test.cs");

            File.WriteAllText(fileName, "class Test {}");

            var window  = new TestWorkbenchWindow();
            var content = new TestViewContentWithDocumentReloadPresenter();

            window.ViewContent = content;
            var doc = new Document(window);

            using (var testCase = new TextEditorExtensionTestCase(doc, content, window, null, false)) {
                content.Document = doc;
                await content.Load(fileName);

                bool reloadWarningDisplayed = false;
                content.OnShowFileChangeWarning = multiple => {
                    reloadWarningDisplayed = true;
                };
                doc.Editor.Text = "class rename {}";
                doc.IsDirty     = true;             // Refactor leaves file unsaved in text editor.
                FilePath newFileName = fileName.ChangeName("renamed");
                FileService.RenameFile(fileName, newFileName);
                // Simulate DefaultWorkbench which updates the view content name when the FileService
                // fires the rename event.
                content.ContentName = newFileName;
                FileService.NotifyFileChanged(newFileName);

                Assert.IsFalse(reloadWarningDisplayed);
            }
        }
Example #2
0
 static string CombineFileName(FilePath path, int i)
 {
     if (i <= 0)
     {
         return(path);
     }
     return(path.ChangeName(path.FileNameWithoutExtension + "~" + i));
 }
Example #3
0
        public override void RenameEntry(string newName)
        {
            var extensionHost = LiteDevelopApplication.Current.ExtensionHost;
            var newPath       = FilePath.ChangeName(newName);

            extensionHost.FileService.MoveFile(FilePath, newPath);
            FilePath = newPath;
        }