public void AddedModuleIsAtCorrectDepth_FirstAnnotation()
        {
            const string inputCode =
                @"'@Folder(""First.Second.Third"")

Sub Foo()
Dim d As Boolean
d = True
End Sub";

            using (var explorer = new MockedCodeExplorer(ProjectType.HostProject, new[] { ComponentType.StandardModule }, new[] { inputCode })
                                  .SelectFirstCustomFolder())
            {
                var project      = explorer.ViewModel.Projects.OfType <CodeExplorerProjectViewModel>().First();
                var folder       = (CodeExplorerCustomFolderViewModel)explorer.ViewModel.SelectedItem;
                var declarations = project.State.AllUserDeclarations.ToList();

                var annotation  = new FolderAnnotation(new QualifiedSelection(project.Declaration.QualifiedModuleName, new Selection(1, 1)), null, new[] { "\"First\"" });
                var predeclared = new PredeclaredIdAnnotation(new QualifiedSelection(project.Declaration.QualifiedModuleName, new Selection(2, 1)), null, Enumerable.Empty <string>());

                declarations.Add(GetNewClassDeclaration(project.Declaration, "Foo", new IAnnotation [] { annotation, predeclared }));

                project.Synchronize(ref declarations);
                var added = folder.Children.OfType <CodeExplorerComponentViewModel>().Single();

                Assert.AreEqual(DeclarationType.ClassModule, added.Declaration.DeclarationType);
                Assert.AreEqual("\"First\"", added.Declaration.CustomFolder);
            }
        }
        public void AnnotateDeclarationRefactoringAction_TextArgument()
        {
            const string code         = @"
Public Sub Foo()
End Sub
";
            const string expectedCode = @"'@Folder ""MyNew""""Folder.MySubFolder""

Public Sub Foo()
End Sub
";
            Func <RubberduckParserState, AnnotateDeclarationModel> modelBuilder = (state) =>
            {
                var module = state.DeclarationFinder
                             .UserDeclarations(DeclarationType.ProceduralModule)
                             .Single();
                var annotation = new FolderAnnotation();
                var arguments  = new List <TypedAnnotationArgument>
                {
                    new TypedAnnotationArgument(AnnotationArgumentType.Text, "MyNew\"Folder.MySubFolder")
                };

                return(new AnnotateDeclarationModel(module, annotation, arguments));
            };

            var refactoredCode = RefactoredCode(code, modelBuilder);

            Assert.AreEqual(expectedCode, refactoredCode);
        }
Exemple #3
0
        private static (IAnnotation annotation, IReadOnlyList <string> annotationArguments) NewAnnotation(string targetFolder)
        {
            var targetFolderLiteral = targetFolder.ToVbaStringLiteral();

            var annotation       = new FolderAnnotation();
            var annotationValues = new List <string> {
                targetFolderLiteral
            };

            return(annotation, annotationValues);
        }
Exemple #4
0
        public void FolderAnnotation_TypeIsFolder()
        {
            var annotation = new FolderAnnotation(new QualifiedSelection(), new[] { "param" });

            Assert.AreEqual(AnnotationType.Folder, annotation.AnnotationType);
        }
Exemple #5
0
        public void FolderAnnotation_TypeIsFolder_NoParam()
        {
            var annotation = new FolderAnnotation(new QualifiedSelection(), new List <string>());

            Assert.AreEqual(AnnotationType.Folder, annotation.AnnotationType);
        }