Example #1
0
        public async Task Rename_Symbol_Should_TriggerUserConfirmationAsync(string oldFilePath, string newFilePath, string sourceCode)
        {
            var userNotificationServices = IUserNotificationServicesFactory.Create();
            var roslynServices           = IRoslynServicesFactory.Implement(new VisualBasicSyntaxFactsService());

            await RenameAsync(sourceCode, oldFilePath, newFilePath, userNotificationServices, roslynServices, LanguageNames.VisualBasic);

            Mock.Get(userNotificationServices).Verify(h => h.Confirm(It.IsAny <string>()), Times.Once);
            Mock.Get(roslynServices).Verify(h => h.RenameSymbolAsync(It.IsAny <Solution>(), It.IsAny <ISymbol>(), It.IsAny <string>(), It.IsAny <CancellationToken>()), Times.Never);
        }
        public async Task Rename_Symbol_Should_TriggerUserConfirmationAsync(string soureCode, string oldFilePath, string newFilePath)
        {
            var userNotificationServices = IUserNotificationServicesFactory.Create();
            var roslynServices           = IRoslynServicesFactory.Create();

            await RenameAsync(soureCode, oldFilePath, newFilePath, userNotificationServices, roslynServices, LanguageNames.CSharp);

            Mock.Get(userNotificationServices).Verify(h => h.Confirm(It.IsAny <string>()), Times.Once);
            Mock.Get(roslynServices).Verify(h => h.RenameSymbolAsync(It.IsAny <Solution>(), It.IsAny <ISymbol>(), It.IsAny <string>()), Times.Never);
        }
        public async Task Rename_Symbol_Should_Not_HappenAsync_ForVB(string soureCode, string oldFilePath, string newFilePath)
        {
            var userNotificationServices = IUserNotificationServicesFactory.Create();
            var roslynServices           = IRoslynServicesFactory.Create();

            await RenameAsync(soureCode, oldFilePath, newFilePath, userNotificationServices, roslynServices, LanguageNames.VisualBasic);

            Mock.Get(userNotificationServices).Verify(h => h.Confirm(It.IsAny <string>()), Times.Never);
            Mock.Get(roslynServices).Verify(h => h.RenameSymbolAsync(It.IsAny <Solution>(), It.IsAny <ISymbol>(), It.IsAny <string>()), Times.Never);
            Mock.Get(roslynServices).Verify(h => h.ApplyChangesToSolution(It.IsAny <Workspace>(), It.IsAny <Solution>()), Times.Never);
        }
        public async Task Rename_Symbol_Should_HappenAsync(string soureCode, string oldFilePath, string newFilePath)
        {
            var userNotificationServices = IUserNotificationServicesFactory.Implement(true);
            var roslynServices           = IRoslynServicesFactory.Implement(DummySolution(), true);

            await RenameAsync(soureCode, oldFilePath, newFilePath, userNotificationServices, roslynServices, LanguageNames.CSharp);

            Mock.Get(userNotificationServices).Verify(h => h.Confirm(It.IsAny <string>()), Times.Once);
            Mock.Get(roslynServices).Verify(h => h.RenameSymbolAsync(It.IsAny <Solution>(), It.IsAny <ISymbol>(), It.IsAny <string>()), Times.Once);
            Mock.Get(roslynServices).Verify(h => h.ApplyChangesToSolution(It.IsAny <Workspace>(), It.IsAny <Solution>()), Times.Once);
        }
Example #5
0
        public async Task Rename_Symbol_Should_Not_HappenAsync(string sourceCode, string oldFilePath, string newFilePath)
        {
            var userNotificationServices = IUserNotificationServicesFactory.Create();
            var roslynServices           = IRoslynServicesFactory.Implement(new CSharpSyntaxFactsService());

            await RenameAsync(sourceCode, oldFilePath, newFilePath, userNotificationServices, roslynServices, LanguageNames.CSharp).TimeoutAfter(TimeSpan.FromSeconds(1));

            Mock.Get(userNotificationServices).Verify(h => h.Confirm(It.IsAny <string>()), Times.Never);
            Mock.Get(roslynServices).Verify(h => h.RenameSymbolAsync(It.IsAny <Solution>(), It.IsAny <ISymbol>(), It.IsAny <string>(), It.IsAny <CancellationToken>()), Times.Never);
            Mock.Get(roslynServices).Verify(h => h.ApplyChangesToSolution(It.IsAny <Workspace>(), It.IsAny <Solution>()), Times.Never);
        }
Example #6
0
        public async Task Rename_Symbol_Should_Not_HappenAsync(string oldFilePath, string newFilePath, string sourceCode)
        {
            var userNotificationServices = IUserNotificationServicesFactory.Create();
            var roslynServices           = IRoslynServicesFactory.Implement(new VisualBasicSyntaxFactsService());
            var vsOnlineServices         = IVsOnlineServicesFactory.Create(online: false);

            await RenameAsync(sourceCode, oldFilePath, newFilePath, userNotificationServices, roslynServices, vsOnlineServices, LanguageNames.VisualBasic);

            Mock.Get(userNotificationServices).Verify(h => h.Confirm(It.IsAny <string>()), Times.Never);
            Mock.Get(roslynServices).Verify(h => h.RenameSymbolAsync(It.IsAny <Solution>(), It.IsAny <ISymbol>(), It.IsAny <string>(), It.IsAny <CancellationToken>()), Times.Never);
            Mock.Get(roslynServices).Verify(h => h.ApplyChangesToSolution(It.IsAny <Workspace>(), It.IsAny <Solution>()), Times.Never);
        }
Example #7
0
        public async Task Rename_Symbol_ShouldNot_TriggerUserConfirmationAsync(string sourceCode, string oldFilePath, string newFilePath)
        {
            var userNotificationServices = IUserNotificationServicesFactory.Create();
            var roslynServices           = IRoslynServicesFactory.Implement(new CSharpSyntaxFactsService());
            var vsOnlineServices         = IVsOnlineServicesFactory.Create(online: false);
            var settingsManagerService   = CreateSettingsManagerService(false);

            await RenameAsync(sourceCode, oldFilePath, newFilePath, userNotificationServices, roslynServices, vsOnlineServices, LanguageNames.CSharp, settingsManagerService);

            bool checkBoxSelection;

            Mock.Get(userNotificationServices).Verify(h => h.Confirm(It.IsAny <string>(), out checkBoxSelection), Times.Never);
            Mock.Get(roslynServices).Verify(h => h.RenameSymbolAsync(It.IsAny <Solution>(), It.IsAny <ISymbol>(), It.IsAny <string>(), It.IsAny <CancellationToken>()), Times.Never);
        }
Example #8
0
        public async Task Rename_Symbol_Should_ExitEarlyInVSOnlineAsync()
        {
            string sourceCode  = "class Foo { }";
            string oldFilePath = "Foo.cs";
            string newFilePath = "Bar.cs";

            var userNotificationServices = IUserNotificationServicesFactory.Create();
            var roslynServices           = IRoslynServicesFactory.Implement(new CSharpSyntaxFactsService());
            var vsOnlineService          = IVsOnlineServicesFactory.Create(online: true);

            await RenameAsync(sourceCode, oldFilePath, newFilePath, userNotificationServices, roslynServices, vsOnlineService, LanguageNames.CSharp);

            Mock.Get(userNotificationServices).Verify(h => h.Confirm(It.IsAny <string>()), Times.Never);
            Mock.Get(roslynServices).Verify(h => h.RenameSymbolAsync(It.IsAny <Solution>(), It.IsAny <ISymbol>(), It.IsAny <string>(), It.IsAny <CancellationToken>()), Times.Never);
            Mock.Get(roslynServices).Verify(h => h.ApplyChangesToSolution(It.IsAny <Workspace>(), It.IsAny <Solution>()), Times.Never);
        }
Example #9
0
        public async Task Rename_Symbol_Should_ExitEarlyInFileExtensionChange(string oldFilePath, string newFilePath)
        {
            string sourceCode = "class Foo { }";

            var userNotificationServices = IUserNotificationServicesFactory.Create();
            var roslynServices           = IRoslynServicesFactory.Implement(new CSharpSyntaxFactsService());
            var vsOnlineService          = IVsOnlineServicesFactory.Create(online: false);
            var settingsManagerService   = CreateSettingsManagerService(true);

            await RenameAsync(sourceCode, oldFilePath, newFilePath, userNotificationServices, roslynServices, vsOnlineService, LanguageNames.CSharp, settingsManagerService);

            bool disablePromptMessage;

            Mock.Get(userNotificationServices).Verify(h => h.Confirm(It.IsAny <string>(), out disablePromptMessage), Times.Never);
            Mock.Get(roslynServices).Verify(h => h.RenameSymbolAsync(It.IsAny <Solution>(), It.IsAny <ISymbol>(), It.IsAny <string>(), It.IsAny <CancellationToken>()), Times.Never);
            Mock.Get(roslynServices).Verify(h => h.ApplyChangesToSolution(It.IsAny <Workspace>(), It.IsAny <Solution>()), Times.Never);
        }