当前位置: 首页>>代码示例>>C#>>正文


C# MockVbeBuilder.ProjectBuilder方法代码示例

本文整理汇总了C#中RubberduckTests.Mocks.MockVbeBuilder.ProjectBuilder方法的典型用法代码示例。如果您正苦于以下问题:C# MockVbeBuilder.ProjectBuilder方法的具体用法?C# MockVbeBuilder.ProjectBuilder怎么用?C# MockVbeBuilder.ProjectBuilder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RubberduckTests.Mocks.MockVbeBuilder的用法示例。


在下文中一共展示了MockVbeBuilder.ProjectBuilder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UseMeaningfulName_ReturnsResult_NameEndsWithDigit

        public void UseMeaningfulName_ReturnsResult_NameEndsWithDigit()
        {
            const string inputCode =
@"Sub Foo1()
End Sub";

            //Arrange
            var builder = new MockVbeBuilder();
            var project = builder.ProjectBuilder("VBAProject", vbext_ProjectProtection.vbext_pp_none)
                .AddComponent("MyClass", vbext_ComponentType.vbext_ct_ClassModule, inputCode)
                .Build();
            var vbe = builder.AddProject(project).Build();

            var mockHost = new Mock<IHostApplication>();
            mockHost.SetupAllProperties();
            var parser = MockParser.Create(vbe.Object, new RubberduckParserState());

            parser.Parse();
            if (parser.State.Status == ParserState.Error) { Assert.Inconclusive("Parser Error"); }

            var inspection = new UseMeaningfulNameInspection(null, parser.State);
            var inspectionResults = inspection.GetInspectionResults();

            Assert.AreEqual(1, inspectionResults.Count());
        }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:25,代码来源:UseMeaningfulNameInspectionTests.cs

示例2: Resolve

        private RubberduckParserState Resolve(params Tuple<string,vbext_ComponentType>[] components)
        {
            var builder = new MockVbeBuilder();
            var projectBuilder = builder.ProjectBuilder("TestProject", vbext_ProjectProtection.vbext_pp_none);
            for (var i = 0; i < components.Length; i++)
            {
                projectBuilder.AddComponent("Component" + (i + 1), components[i].Item2, components[i].Item1);
            }

            var project = projectBuilder.Build();
            builder.AddProject(project);
            var vbe = builder.Build();

            var parser = MockParser.Create(vbe.Object, new RubberduckParserState());

            parser.Parse();
            if (parser.State.Status != ParserState.Ready)
            {
                Assert.Inconclusive("Parser state should be 'Ready', but returns '{0}'.", parser.State.Status);
            }

            return parser.State;
        }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:23,代码来源:ResolverTests.cs

示例3: DefaultProjectName_DoesNotReturnResult

        public void DefaultProjectName_DoesNotReturnResult()
        {
            const string inputCode = @"";

            //Arrange
            var builder = new MockVbeBuilder();
            var project = builder.ProjectBuilder("TestProject", vbext_ProjectProtection.vbext_pp_none)
                .AddComponent("Class1", vbext_ComponentType.vbext_ct_ClassModule, inputCode)
                .Build();
            var vbe = builder.AddProject(project).Build();

            var mockHost = new Mock<IHostApplication>();
            mockHost.SetupAllProperties();
            var parser = MockParser.Create(vbe.Object, new RubberduckParserState());

            parser.Parse();
            if (parser.State.Status == ParserState.Error) { Assert.Inconclusive("Parser Error"); }

            var inspection = new DefaultProjectNameInspection(parser.State);
            var inspectionResults = inspection.GetInspectionResults();

            Assert.AreEqual(0, inspectionResults.Count());
        }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:23,代码来源:DefaultProjectNameInspectionTests.cs

示例4: IntroduceParameterRefactoring_ImplementsInterface_Reject

        public void IntroduceParameterRefactoring_ImplementsInterface_Reject()
        {
            //Input
            const string inputCode1 =
            @"Sub fizz(ByVal boo As Boolean)
End Sub";

            const string inputCode2 =
@"Implements IClass1

Sub IClass1_fizz(ByVal boo As Boolean)
    Dim fizz As Date
End Sub";
            var selection = new Selection(4, 10, 4, 14);

            //Arrange
            var builder = new MockVbeBuilder();
            var project = builder.ProjectBuilder("TestProject1", vbext_ProjectProtection.vbext_pp_none)
                .AddComponent("IClass1", vbext_ComponentType.vbext_ct_ClassModule, inputCode1)
                .AddComponent("Class1", vbext_ComponentType.vbext_ct_ClassModule, inputCode2)
                .Build();
            var vbe = builder.AddProject(project).Build();
            var component = project.Object.VBComponents.Item(1);
            vbe.Setup(v => v.ActiveCodePane).Returns(component.CodeModule.CodePane);

            var codePaneFactory = new CodePaneWrapperFactory();
            var mockHost = new Mock<IHostApplication>();
            mockHost.SetupAllProperties();
            var parser = MockParser.Create(vbe.Object, new RubberduckParserState());

            parser.Parse();
            if (parser.State.Status == ParserState.Error) { Assert.Inconclusive("Parser Error"); }

            var qualifiedSelection = new QualifiedSelection(new QualifiedModuleName(component), selection);

            var module1 = project.Object.VBComponents.Item(0).CodeModule;
            var module2 = project.Object.VBComponents.Item(1).CodeModule;

            var messageBox = new Mock<IMessageBox>();
            messageBox.Setup(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxButtons>(), It.IsAny<MessageBoxIcon>()))
                      .Returns(DialogResult.No);

            //Act
            var refactoring = new IntroduceParameterRefactoring(parser.State, new ActiveCodePaneEditor(vbe.Object, codePaneFactory), messageBox.Object);
            refactoring.Refactor(qualifiedSelection);

            //Assert
            Assert.AreEqual(inputCode1, module1.Lines());
            Assert.AreEqual(inputCode2, module2.Lines());
        }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:50,代码来源:IntroduceParameterTests.cs

示例5: FunctionReturnValueNotUsed_QuickFixWorks_Interface

        public void FunctionReturnValueNotUsed_QuickFixWorks_Interface()
        {
            const string inputInterfaceCode =
@"Public Function Test() As Integer
End Function";

            const string expectedInterfaceCode =
@"Public Sub Test()
End Sub";

            const string inputImplementationCode1 =
@"Implements IFoo
Public Function IFoo_Test() As Integer
    IFoo_Test = 42
End Function";

            const string expectedImplementationCode1 =
@"Implements IFoo
Public Sub IFoo_Test()
End Sub";

            const string inputImplementationCode2 =
@"Implements IFoo
Public Function IFoo_Test() As Integer
    IFoo_Test = 42
End Function";

            const string expectedImplementationCode2 =
@"Implements IFoo
Public Sub IFoo_Test()
End Sub";

            const string callSiteCode =
@"
Public Function Baz()
    Dim testObj As IFoo
    Set testObj = new Bar()
    testObj.Test
End Function";

            //Arrange
            var builder = new MockVbeBuilder();
            var projectBuilder = builder.ProjectBuilder("TestProject", vbext_ProjectProtection.vbext_pp_none);
            projectBuilder.AddComponent("IFoo", vbext_ComponentType.vbext_ct_ClassModule, inputInterfaceCode);
            projectBuilder.AddComponent("Bar", vbext_ComponentType.vbext_ct_ClassModule, inputImplementationCode1);
            projectBuilder.AddComponent("Bar2", vbext_ComponentType.vbext_ct_ClassModule, inputImplementationCode2);
            projectBuilder.AddComponent("TestModule", vbext_ComponentType.vbext_ct_StdModule, callSiteCode);
            var vbe = projectBuilder.MockVbeBuilder().Build();
            var mockHost = new Mock<IHostApplication>();
            mockHost.SetupAllProperties();
            var parser = MockParser.Create(vbe.Object, new RubberduckParserState());

            parser.Parse();
            if (parser.State.Status == ParserState.Error) { Assert.Inconclusive("Parser Error"); }

            var inspection = new FunctionReturnValueNotUsedInspection(parser.State);
            var inspectionResults = inspection.GetInspectionResults();

            inspectionResults.First().QuickFixes.First().Fix();

            var project = vbe.Object.VBProjects.Item(0);
            var interfaceModule = project.VBComponents.Item(0).CodeModule;
            string actualInterface = interfaceModule.Lines();
            Assert.AreEqual(expectedInterfaceCode, actualInterface, "Interface");
            var implementationModule1 = project.VBComponents.Item(1).CodeModule;
            string actualImplementation1 = implementationModule1.Lines();
            //Assert.AreEqual(expectedImplementationCode1, actualImplementation1, "Implementation1");
            var implementationModule2 = project.VBComponents.Item(2).CodeModule;
            string actualImplementation2 = implementationModule2.Lines();
            //Assert.AreEqual(expectedImplementationCode2, actualImplementation2, "Implementation2");
        }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:71,代码来源:FunctionReturnValueNotUsedInspectionTests.cs

示例6: FunctionReturnValueNotUsed_ReturnsResult_InterfaceMember

        public void FunctionReturnValueNotUsed_ReturnsResult_InterfaceMember()
        {
            const string interfaceCode =
@"Public Function Test() As Integer
End Function";

            const string implementationCode =
@"Implements IFoo
Public Function IFoo_Test() As Integer
    IFoo_Test = 42
End Function";

            const string callSiteCode =
@"
Public Sub Baz()
    Dim testObj As IFoo
    Set testObj = new Bar()
    testObj.Test
End Sub";

            //Arrange
            var builder = new MockVbeBuilder();
            var projectBuilder = builder.ProjectBuilder("TestProject", vbext_ProjectProtection.vbext_pp_none);
            projectBuilder.AddComponent("IFoo", vbext_ComponentType.vbext_ct_ClassModule, interfaceCode);
            projectBuilder.AddComponent("Bar", vbext_ComponentType.vbext_ct_ClassModule, implementationCode);
            projectBuilder.AddComponent("TestModule", vbext_ComponentType.vbext_ct_StdModule, callSiteCode);
            var vbe = projectBuilder.MockVbeBuilder().Build();
            var mockHost = new Mock<IHostApplication>();
            mockHost.SetupAllProperties();
            var parser = MockParser.Create(vbe.Object, new RubberduckParserState());

            parser.Parse();
            if (parser.State.Status == ParserState.Error) { Assert.Inconclusive("Parser Error"); }

            var inspection = new FunctionReturnValueNotUsedInspection(parser.State);
            var inspectionResults = inspection.GetInspectionResults();

            Assert.AreEqual(1, inspectionResults.Count());
        }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:39,代码来源:FunctionReturnValueNotUsedInspectionTests.cs

示例7: ProcedureShouldBeFunction_DoesNotReturnResult_EventImplementation

        public void ProcedureShouldBeFunction_DoesNotReturnResult_EventImplementation()
        {
            //Input
            const string inputCode1 =
@"Public Event Foo(ByRef arg1 As Integer)";
            const string inputCode2 =
@"Private WithEvents abc As Class1

Private Sub abc_Foo(ByRef arg1 As Integer)
End Sub";

            //Arrange
            var builder = new MockVbeBuilder();
            var project = builder.ProjectBuilder("TestProject1", vbext_ProjectProtection.vbext_pp_none)
                .AddComponent("Class1", vbext_ComponentType.vbext_ct_ClassModule, inputCode1)
                .AddComponent("Class2", vbext_ComponentType.vbext_ct_ClassModule, inputCode2)
                .Build();
            var vbe = builder.AddProject(project).Build();

            var mockHost = new Mock<IHostApplication>();
            mockHost.SetupAllProperties();
            var parser = MockParser.Create(vbe.Object, new RubberduckParserState());

            parser.Parse();
            if (parser.State.Status == ParserState.Error) { Assert.Inconclusive("Parser Error"); }

            var inspection = new ProcedureCanBeWrittenAsFunctionInspection(parser.State);
            var inspectionResults = inspection.GetInspectionResults();

            Assert.AreEqual(0, inspectionResults.Count());
        }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:31,代码来源:ProcedureShouldBeFunctionInspectionTests.cs

示例8: Presenter_NullTargetReturnsNullModel

        public void Presenter_NullTargetReturnsNullModel()
        {
            //Input
            const string inputCode =
@"
Private Sub Foo(ByVal arg1 As Integer, ByVal arg2 As String)
End Sub";
            var selection = Selection.Home;

            //Arrange
            var builder = new MockVbeBuilder();
            var projectBuilder = builder.ProjectBuilder("TestProject1", vbext_ProjectProtection.vbext_pp_none);
            projectBuilder.AddComponent("Module1", vbext_ComponentType.vbext_ct_StdModule, inputCode);
            var project = projectBuilder.Build();
            builder.AddProject(project);
            var vbe = builder.Build();

            var codePaneFactory = new CodePaneWrapperFactory();
            var mockHost = new Mock<IHostApplication>();
            mockHost.SetupAllProperties();
            var parser = MockParser.Create(vbe.Object, new RubberduckParserState());

            parser.Parse();
            if (parser.State.Status == ParserState.Error) { Assert.Inconclusive("Parser Error"); }

            var codePane = project.Object.VBComponents.Item(0).CodeModule.CodePane;
            var ext = codePaneFactory.Create(codePane);
            ext.Selection = selection;

            var qualifiedSelection = new QualifiedSelection(new QualifiedModuleName(codePane.CodeModule.Parent), selection);

            var editor = new Mock<IActiveCodePaneEditor>();
            editor.Setup(e => e.GetSelection()).Returns(qualifiedSelection);

            var factory = new EncapsulateFieldPresenterFactory(parser.State, editor.Object, null);

            var presenter = factory.Create();

            Assert.AreEqual(null, presenter.Show());
        }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:40,代码来源:EncapsulateFieldTests.cs

示例9: Factory_NullSelectionReturnsNullPresenter

        public void Factory_NullSelectionReturnsNullPresenter()
        {
            //Input
            const string inputCode =
@"Private fizz As Integer";

            //Arrange
            var builder = new MockVbeBuilder();
            var projectBuilder = builder.ProjectBuilder("TestProject1", vbext_ProjectProtection.vbext_pp_none);
            projectBuilder.AddComponent("Module1", vbext_ComponentType.vbext_ct_StdModule, inputCode);
            var project = projectBuilder.Build();
            builder.AddProject(project);
            var vbe = builder.Build();

            var mockHost = new Mock<IHostApplication>();
            mockHost.SetupAllProperties();
            var parser = MockParser.Create(vbe.Object, new RubberduckParserState());

            parser.Parse();
            if (parser.State.Status == ParserState.Error) { Assert.Inconclusive("Parser Error"); }

            var editor = new Mock<IActiveCodePaneEditor>();
            editor.Setup(e => e.GetSelection()).Returns((QualifiedSelection?)null);

            var factory = new EncapsulateFieldPresenterFactory(parser.State, editor.Object, null);

            Assert.AreEqual(null, factory.Create());
        }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:28,代码来源:EncapsulateFieldTests.cs

示例10: GivenReferencedPublicField_UpdatesReferenceToNewProperty

        public void GivenReferencedPublicField_UpdatesReferenceToNewProperty()
        {
            //Input
            const string code_class1 =
@"Public fizz As Integer

Sub Foo()
    fizz = 1
End Sub";
            const string code_class2 =
@"Sub Foo()
    Dim c As Class1
    c.fizz = 0
    Bar c.fizz
End Sub

Sub Bar(ByVal v As Integer)
End Sub";

            var selection = new Selection(1, 1, 1, 1);

            //Expectation
            const string expectedCode1 =
@"Private fizz As Integer

Public Property Get Name() As Integer
    Name = fizz
End Property

Public Property Let Name(ByVal value As Integer)
    fizz = value
End Property

Sub Foo()
    Name = 1
End Sub";

            const string expectedCode2 =
@"Sub Foo()
    Dim c As Class1
    c.Name = 0
    Bar c.Name
End Sub

Sub Bar(ByVal v As Integer)
End Sub";

            //Arrange
            var builder = new MockVbeBuilder();
            var project = builder.ProjectBuilder("TestProject1", vbext_ProjectProtection.vbext_pp_none)
                .AddComponent("Class1", vbext_ComponentType.vbext_ct_ClassModule, code_class1)
                .AddComponent("Class2", vbext_ComponentType.vbext_ct_ClassModule, code_class2)
                .Build();
            var vbe = builder.AddProject(project).Build();
            var component = project.Object.VBComponents.Item(0);
            vbe.Setup(v => v.ActiveCodePane).Returns(component.CodeModule.CodePane);

            var codePaneFactory = new CodePaneWrapperFactory();
            var mockHost = new Mock<IHostApplication>();
            mockHost.SetupAllProperties();
            var parser = MockParser.Create(vbe.Object, new RubberduckParserState());

            parser.Parse();
            if (parser.State.Status == ParserState.Error) { Assert.Inconclusive("Parser Error"); }

            var qualifiedSelection = new QualifiedSelection(new QualifiedModuleName(component), selection);

            var module1 = project.Object.VBComponents.Item(0).CodeModule;
            var module2 = project.Object.VBComponents.Item(1).CodeModule;

            var model = new EncapsulateFieldModel(parser.State, qualifiedSelection)
            {
                ImplementLetSetterType = true,
                ImplementSetSetterType = false,
                ParameterName = "value",
                PropertyName = "Name"
            };

            //SetupFactory
            var factory = SetupFactory(model);

            //Act
            var refactoring = new EncapsulateFieldRefactoring(factory.Object, new ActiveCodePaneEditor(vbe.Object, codePaneFactory));
            refactoring.Refactor(qualifiedSelection);

            var actualCode1 = module1.Lines();
            var actualCode2 = module2.Lines();

            //Assert
            Assert.AreEqual(expectedCode1, actualCode1);
            Assert.AreEqual(expectedCode2, actualCode2);
        }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:92,代码来源:EncapsulateFieldTests.cs

示例11: RenameRefactoring_RenameCodeModule

        public void RenameRefactoring_RenameCodeModule()
        {
            const string newName = "RenameModule";

            //Input
            const string inputCode =
@"Private Sub Foo(ByVal a As Integer, ByVal b As String)
End Sub";

            var selection = new Selection(3, 27, 3, 27);

            //Arrange
            var builder = new MockVbeBuilder();
            var project = builder.ProjectBuilder("TestProject1", vbext_ProjectProtection.vbext_pp_none)
                .AddComponent("Class1", vbext_ComponentType.vbext_ct_ClassModule, inputCode)
                .Build();
            var vbe = builder.AddProject(project).Build();
            var component = project.Object.VBComponents.Item(0);

            var codePaneFactory = new CodePaneWrapperFactory();
            var mockHost = new Mock<IHostApplication>();
            mockHost.SetupAllProperties();
            var parser = MockParser.Create(vbe.Object, new RubberduckParserState());

            parser.Parse();
            if (parser.State.Status == ParserState.Error) { Assert.Inconclusive("Parser Error"); }

            var qualifiedSelection = new QualifiedSelection(new QualifiedModuleName(component), selection);

            var model = new RenameModel(vbe.Object, parser.State, qualifiedSelection, null) { NewName = newName };
            model.Target = model.Declarations.FirstOrDefault(i => i.DeclarationType == DeclarationType.Class && i.IdentifierName == "Class1");

            //SetupFactory
            var factory = SetupFactory(model);

            //Act
            var refactoring = new RenameRefactoring(factory.Object, new ActiveCodePaneEditor(vbe.Object, codePaneFactory), null, parser.State);
            refactoring.Refactor(model.Target);

            //Assert
            Assert.AreSame(newName, component.CodeModule.Name);
        }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:42,代码来源:RenameTests.cs

示例12: OptionBaseOnePartiallySpecified_ReturnsResults

        public void OptionBaseOnePartiallySpecified_ReturnsResults()
        {
            const string inputCode1 = @"";
            const string inputCode2 = @"Option Base 1";

            //Arrange
            var builder = new MockVbeBuilder();
            var project = builder.ProjectBuilder("TestProject1", vbext_ProjectProtection.vbext_pp_none)
                .AddComponent("Class1", vbext_ComponentType.vbext_ct_ClassModule, inputCode1)
                .AddComponent("Class2", vbext_ComponentType.vbext_ct_ClassModule, inputCode2)
                .Build();
            var vbe = builder.AddProject(project).Build();

            var mockHost = new Mock<IHostApplication>();
            mockHost.SetupAllProperties();
            var parser = MockParser.Create(vbe.Object, new RubberduckParserState());

            parser.Parse();
            if (parser.State.Status == ParserState.Error) { Assert.Inconclusive("Parser Error"); }

            var inspection = new OptionBaseInspection(parser.State);
            var inspectionResults = inspection.GetInspectionResults();

            Assert.AreEqual(1, inspectionResults.Count());
        }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:25,代码来源:OptionBaseInspectionTests.cs

示例13: ProcedureNotUsed_NoResultForClassInitialize

        public void ProcedureNotUsed_NoResultForClassInitialize()
        {
            //Input
            const string inputCode =
@"Private Sub Class_Initialize()
End Sub";

            //Arrange
            var builder = new MockVbeBuilder();
            var vbe = builder.ProjectBuilder("TestProject", vbext_ProjectProtection.vbext_pp_none)
                             .AddComponent("TestClass", vbext_ComponentType.vbext_ct_ClassModule, inputCode)
                             .MockVbeBuilder().Build();
                             
            var mockHost = new Mock<IHostApplication>();
            mockHost.SetupAllProperties();
            var parser = MockParser.Create(vbe.Object, new RubberduckParserState());

            parser.Parse();
            if (parser.State.Status == ParserState.Error) { Assert.Inconclusive("Parser Error"); }

            var inspection = new ProcedureNotUsedInspection(parser.State);
            var inspectionResults = inspection.GetInspectionResults();

            Assert.AreEqual(0, inspectionResults.Count());
        }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:25,代码来源:ProcedureNotUsedInspectionTests.cs

示例14: ReorderParametersRefactoring_EventParamsSwapped_DifferentParamNames_TwoHandlers

        public void ReorderParametersRefactoring_EventParamsSwapped_DifferentParamNames_TwoHandlers()
        {
            //Input
            const string inputCode1 =
@"Public Event Foo(ByVal arg1 As Integer, ByVal arg2 As String)";

            const string inputCode2 =
@"Private WithEvents abc As Class1

Private Sub abc_Foo(ByVal i As Integer, ByVal s As String)
End Sub";
            const string inputCode3 =
@"Private WithEvents abc As Class1

Private Sub abc_Foo(ByVal v1 As Integer, ByVal v2 As String)
End Sub";

            var selection = new Selection(1, 15, 1, 15);

            //Expectation
            const string expectedCode1 =
@"Public Event Foo(ByVal arg2 As String, ByVal arg1 As Integer)";

            const string expectedCode2 =
@"Private WithEvents abc As Class1

Private Sub abc_Foo(ByVal s As String, ByVal i As Integer)
End Sub";   // note: IDE removes excess spaces

            const string expectedCode3 =
@"Private WithEvents abc As Class1

Private Sub abc_Foo(ByVal v2 As String, ByVal v1 As Integer)
End Sub";   // note: IDE removes excess spaces

            //Arrange
            var builder = new MockVbeBuilder();
            var project = builder.ProjectBuilder("TestProject1", vbext_ProjectProtection.vbext_pp_none)
                .AddComponent("Class1", vbext_ComponentType.vbext_ct_ClassModule, inputCode1)
                .AddComponent("Class2", vbext_ComponentType.vbext_ct_ClassModule, inputCode2)
                .AddComponent("Class3", vbext_ComponentType.vbext_ct_ClassModule, inputCode3)
                .Build();
            var vbe = builder.AddProject(project).Build();
            var component = project.Object.VBComponents.Item(0);

            var codePaneFactory = new CodePaneWrapperFactory();
            var mockHost = new Mock<IHostApplication>();
            mockHost.SetupAllProperties();
            var parser = MockParser.Create(vbe.Object, new RubberduckParserState());

            parser.Parse();
            if (parser.State.Status == ParserState.Error) { Assert.Inconclusive("Parser Error"); }

            var qualifiedSelection = new QualifiedSelection(new QualifiedModuleName(component), selection);
            var module1 = project.Object.VBComponents.Item(0).CodeModule;
            var module2 = project.Object.VBComponents.Item(1).CodeModule;
            var module3 = project.Object.VBComponents.Item(2).CodeModule;

            //Specify Params to remove
            var model = new ReorderParametersModel(parser.State, qualifiedSelection, null);
            model.Parameters.Reverse();

            //SetupFactory
            var factory = SetupFactory(model);

            //Act
            var refactoring = new ReorderParametersRefactoring(factory.Object, new ActiveCodePaneEditor(vbe.Object, codePaneFactory), null);
            refactoring.Refactor(qualifiedSelection);

            //Assert
            Assert.AreEqual(expectedCode1, module1.Lines());
            Assert.AreEqual(expectedCode2, module2.Lines());
            Assert.AreEqual(expectedCode3, module3.Lines());
        }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:74,代码来源:ReorderParametersTests.cs

示例15: ReorderParametersRefactoring_ParamsSwapped_RejectPrompt

        public void ReorderParametersRefactoring_ParamsSwapped_RejectPrompt()
        {
            //Input
            const string inputCode1 =
@"Implements IClass1

Private Sub IClass1_DoSomething(ByVal a As Integer, ByVal b As String)
End Sub";
            const string inputCode2 =
@"Public Sub DoSomething(ByVal a As Integer, ByVal b As String)
End Sub";

            var selection = new Selection(3, 23, 3, 27);

            //Arrange
            var builder = new MockVbeBuilder();
            var project = builder.ProjectBuilder("TestProject1", vbext_ProjectProtection.vbext_pp_none)
                .AddComponent("Class1", vbext_ComponentType.vbext_ct_ClassModule, inputCode1)
                .AddComponent("IClass1", vbext_ComponentType.vbext_ct_ClassModule, inputCode2)
                .Build();
            var vbe = builder.AddProject(project).Build();
            var component = project.Object.VBComponents.Item(0);

            var mockHost = new Mock<IHostApplication>();
            mockHost.SetupAllProperties();
            var parser = MockParser.Create(vbe.Object, new RubberduckParserState());

            parser.Parse();
            if (parser.State.Status == ParserState.Error) { Assert.Inconclusive("Parser Error"); }

            var qualifiedSelection = new QualifiedSelection(new QualifiedModuleName(component), selection);

            var messageBox = new Mock<IMessageBox>();
            messageBox.Setup(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxButtons>(), It.IsAny<MessageBoxIcon>()))
                      .Returns(DialogResult.No);

            //Specify Params to remove
            var model = new ReorderParametersModel(parser.State, qualifiedSelection, messageBox.Object);
            Assert.IsNull(model.TargetDeclaration);
        }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:40,代码来源:ReorderParametersTests.cs


注:本文中的RubberduckTests.Mocks.MockVbeBuilder.ProjectBuilder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。