예제 #1
0
        public void EncapsulateField_CanExecute_NonReadyState()
        {
            IVBComponent component;
            var          vbe   = MockVbeBuilder.BuildFromSingleStandardModule(string.Empty, out component);
            var          state = MockParser.CreateAndParse(vbe.Object);

            state.SetStatusAndFireStateChanged(this, ParserState.ResolvedDeclarations);

            var encapsulateFieldCommand = new RefactorEncapsulateFieldCommand(vbe.Object, state, null);

            Assert.IsFalse(encapsulateFieldCommand.CanExecute(null));
        }
예제 #2
0
        public void EncapsulateField_CanExecute_NullActiveCodePane()
        {
            IVBComponent component;
            var          vbe = MockVbeBuilder.BuildFromSingleStandardModule(string.Empty, out component);

            vbe.Setup(v => v.ActiveCodePane).Returns((ICodePane)null);

            using (var state = MockParser.CreateAndParse(vbe.Object))
            {
                var encapsulateFieldCommand = new RefactorEncapsulateFieldCommand(vbe.Object, state, null);
                Assert.IsFalse(encapsulateFieldCommand.CanExecute(null));
            }
        }
        public void EncapsulateField_CanExecute_NonReadyState()
        {
            var vbe = MockVbeBuilder.BuildFromSingleStandardModule(string.Empty, out _);

            var(state, rewritingManager) = MockParser.CreateAndParseWithRewritingManager(vbe.Object);
            using (state)
            {
                state.SetStatusAndFireStateChanged(this, ParserState.ResolvedDeclarations, CancellationToken.None);

                var encapsulateFieldCommand = new RefactorEncapsulateFieldCommand(vbe.Object, state, null, rewritingManager);
                Assert.IsFalse(encapsulateFieldCommand.CanExecute(null));
            }
        }
        public void EncapsulateField_CanExecute_NullActiveCodePane()
        {
            var vbe = MockVbeBuilder.BuildFromSingleStandardModule(string.Empty, out _);

            vbe.Setup(v => v.ActiveCodePane).Returns((ICodePane)null);

            var(state, rewritingManager) = MockParser.CreateAndParseWithRewritingManager(vbe.Object);
            using (state)
            {
                var encapsulateFieldCommand = new RefactorEncapsulateFieldCommand(vbe.Object, state, null, rewritingManager);
                Assert.IsFalse(encapsulateFieldCommand.CanExecute(null));
            }
        }
예제 #5
0
        public void EncapsulateField_CanExecute_Field()
        {
            var input =
                @"Dim d As Boolean
Sub Foo()
End Sub";

            IVBComponent component;
            var          vbe   = MockVbeBuilder.BuildFromSingleStandardModule(input, out component, new Selection(1, 5, 1, 5));
            var          state = MockParser.CreateAndParse(vbe.Object);

            var encapsulateFieldCommand = new RefactorEncapsulateFieldCommand(vbe.Object, state, null);

            Assert.IsTrue(encapsulateFieldCommand.CanExecute(null));
        }
예제 #6
0
        public void EncapsulateField_CanExecute_LocalVariable()
        {
            var input =
                @"Sub Foo()
    Dim d As Boolean
End Sub";

            IVBComponent component;
            var          vbe = MockVbeBuilder.BuildFromSingleStandardModule(input, out component, new Selection(2, 9, 2, 9));

            using (var state = MockParser.CreateAndParse(vbe.Object))
            {
                var encapsulateFieldCommand = new RefactorEncapsulateFieldCommand(vbe.Object, state, null);
                Assert.IsFalse(encapsulateFieldCommand.CanExecute(null));
            }
        }
        public void EncapsulateField_CanExecute_Field()
        {
            var input =
                @"Dim d As Boolean
Sub Foo()
End Sub";

            var vbe = MockVbeBuilder.BuildFromSingleStandardModule(input, out _, new Selection(1, 5, 1, 5));

            var(state, rewritingManager) = MockParser.CreateAndParseWithRewritingManager(vbe.Object);
            using (state)
            {
                var encapsulateFieldCommand = new RefactorEncapsulateFieldCommand(vbe.Object, state, null, rewritingManager);
                Assert.IsTrue(encapsulateFieldCommand.CanExecute(null));
            }
        }
예제 #8
0
 public RefactorEncapsulateFieldCommandMenuItem(RefactorEncapsulateFieldCommand command)
     : base(command)
 {
 }