public void AnnotateDeclarationRefactoringAction_WorksWithExistingAnnotation_Member()
        {
            const string code         = @"Attribute VB_Exposed = False
'@Folder ""MyFolder""
'@DefaultMember
Public Sub Foo()
End Sub
";
            const string expectedCode = @"Attribute VB_Exposed = False
'@Folder ""MyFolder""
'@DefaultMember
'@Description ""MyDesc""
Public Sub Foo()
Attribute Foo.VB_Description = ""MyDesc""
End Sub
";
            Func <RubberduckParserState, AnnotateDeclarationModel> modelBuilder = (state) =>
            {
                var declaration = state.DeclarationFinder
                                  .UserDeclarations(DeclarationType.Procedure)
                                  .Single();
                var annotation = new DescriptionAnnotation();
                var arguments  = new List <TypedAnnotationArgument>
                {
                    new TypedAnnotationArgument(AnnotationArgumentType.Text, "MyDesc")
                };

                return(new AnnotateDeclarationModel(declaration, annotation, arguments, true));
            };

            var refactoredCode = RefactoredCode(code, modelBuilder);

            Assert.AreEqual(expectedCode, refactoredCode);
        }
        public void AnnotateDeclarationRefactoringAction_AdjustAttributeSet_AttributeAlreadyThere_AdjustsAttribute_Member()
        {
            const string code         = @"
Public Sub Foo()
Attribute Foo.VB_Description = ""NotMyDesc""
End Sub
";
            const string expectedCode = @"
'@Description ""MyDesc""
Public Sub Foo()
Attribute Foo.VB_Description = ""MyDesc""
End Sub
";
            Func <RubberduckParserState, AnnotateDeclarationModel> modelBuilder = (state) =>
            {
                var declaration = state.DeclarationFinder
                                  .UserDeclarations(DeclarationType.Procedure)
                                  .Single();
                var annotation = new DescriptionAnnotation();
                var arguments  = new List <TypedAnnotationArgument>
                {
                    new TypedAnnotationArgument(AnnotationArgumentType.Text, "MyDesc")
                };

                return(new AnnotateDeclarationModel(declaration, annotation, arguments, true));
            };

            var refactoredCode = RefactoredCode(code, modelBuilder);

            Assert.AreEqual(expectedCode, refactoredCode);
        }
        public void SetAnnotation_SetsAnnotationOnModel()
        {
            var viewModel  = TestViewModel(DeclarationType.Procedure);
            var annotation = new DescriptionAnnotation();

            viewModel.Annotation = annotation;

            Assert.AreSame(viewModel.Model.Annotation, annotation);
        }
        public void ShowAdjustAttributeOption_AttributeAnnotation_True()
        {
            var viewModel  = TestViewModel(DeclarationType.Procedure);
            var annotation = new DescriptionAnnotation();

            viewModel.Annotation = annotation;

            Assert.IsTrue(viewModel.ShowAdjustAttributeOption);
        }
Exemplo n.º 5
0
        public void DescriptionAnnotation_TypeIsDescription()
        {
            var annotation = new DescriptionAnnotation(new QualifiedSelection(), null, null);

            Assert.AreEqual(AnnotationType.Description, annotation.AnnotationType);
        }
Exemplo n.º 6
0
 public void Process(DescriptionAnnotation annotation)
 {
     entityDefinition.Description = annotation.Value;
 }
Exemplo n.º 7
0
 public void Process(DescriptionAnnotation annotation)
 {
     attribute.Description = annotation.Value;
 }