public void AnnotateDeclarationRefactoringAction_NoArgument()
        {
            const string code         = @"
Public Sub Foo()
End Sub
";
            const string expectedCode = @"'@Exposed

Public Sub Foo()
End Sub
";
            Func <RubberduckParserState, AnnotateDeclarationModel> modelBuilder = (state) =>
            {
                var module = state.DeclarationFinder
                             .UserDeclarations(DeclarationType.ProceduralModule)
                             .Single();
                var annotation = new ExposedModuleAnnotation();
                var arguments  = new List <TypedAnnotationArgument>();

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

            var refactoredCode = RefactoredCode(code, modelBuilder);

            Assert.AreEqual(expectedCode, refactoredCode);
        }
Esempio n. 2
0
        private static string InterfaceModuleBody(ExtractInterfaceModel model)
        {
            var interfaceMembers = string.Join(NewLines.DOUBLE_SPACE, model.SelectedMembers.Select(m => m.Body));
            var optionExplicit   = $"{Tokens.Option} {Tokens.Explicit}{Environment.NewLine}";

            var targetModule         = Declaration.GetModuleParent(model.TargetDeclaration);
            var folderAnnotation     = targetModule?.Annotations.FirstOrDefault(pta => pta.Annotation is FolderAnnotation);
            var folderAnnotationText = folderAnnotation != null
                                       ? $"'@{folderAnnotation.Context.GetText()}{Environment.NewLine}"
                                       : string.Empty;

            var exposedAnnotation     = new ExposedModuleAnnotation();
            var exposedAnnotationText = model.InterfaceInstancing == ClassInstancing.Public
                ? $"'@{exposedAnnotation.Name}{Environment.NewLine}"
                : string.Empty;

            var interfaceAnnotation     = new InterfaceAnnotation();
            var interfaceAnnotationText = $"'@{interfaceAnnotation.Name}{Environment.NewLine}";

            return($"{optionExplicit}{Environment.NewLine}{folderAnnotationText}{exposedAnnotationText}{interfaceAnnotationText}{Environment.NewLine}{interfaceMembers}");
        }
        public void ExposedModuleAnnotation_TypeIsExposed()
        {
            var annotation = new ExposedModuleAnnotation(new QualifiedSelection(), null, null);

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