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


C# Mock.ImplementExpr方法代码示例

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


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

示例1: VsGetEnumeratorSelectedProjectsTest

 public void VsGetEnumeratorSelectedProjectsTest()
 {
     ProjectCollection target = new ProjectCollection();
     Mock<IEnumerable> mockEnumerable = new Mock<IEnumerable>();
     Mock<IEnumerator> mockEnumerator = new Mock<IEnumerator>();
     IEnumerator expected = mockEnumerator.Instance;
     mockEnumerable.ImplementExpr(e => e.GetEnumerator(), expected);
     target.SelectedProjects = mockEnumerable.Instance;
     IEnumerator actual;
     actual = target.GetEnumerator();
     Assert.AreEqual(expected, actual);
 }
开发者ID:jonthegiant,项目名称:StyleCop,代码行数:12,代码来源:ProjectCollectionTest.cs

示例2: PackageCommandSetConstructorTest

        public void PackageCommandSetConstructorTest()
        {
            var mockActiveDocument = new Mock<Document>();
            var mockDte = new Mock<DTE>();

            mockDte.ImplementExpr(dte => dte.ActiveDocument, mockActiveDocument.Instance);

            this.mockServiceProvider.ImplementExpr(sp => sp.GetService(typeof(EnvDTE.DTE)), mockDte.Instance);

            PackageCommandSet_Accessor target = new PackageCommandSet_Accessor(this.mockServiceProvider.Instance);
            CommandSet_Accessor innerTarget = new PackageCommandSet_Accessor(this.mockServiceProvider.Instance);
            Assert.IsNotNull(target.CommandList, "CommandList was not created.");
            Assert.IsNotNull(innerTarget.ServiceProvider, "Service provider not stored by the constructor");
        }
开发者ID:kjata30,项目名称:StyleCop,代码行数:14,代码来源:PackageCommandSetTest.cs

示例3: VsOutputPanePropertyTest

        public void VsOutputPanePropertyTest()
        {
            // Setup
            Mock<EnvDTE.Window> mockWindow = SetupMockWindow();
            Mock<EnvDTE.OutputWindow> mockOutputWindow = new Mock<EnvDTE.OutputWindow>();
            mockWindow.ImplementExpr(w => w.Object, (EnvDTE.OutputWindow)mockOutputWindow.Instance);
            Mock<EnvDTE.OutputWindowPane> mockOutputWindowPane = new Mock<EnvDTE.OutputWindowPane>();
            Mock<EnvDTE.OutputWindowPanes> mockOutputWindowPanes = new Mock<EnvDTE.OutputWindowPanes>();
            mockOutputWindow.ImplementExpr(ow => ow.OutputWindowPanes, (EnvDTE.OutputWindowPanes)mockOutputWindowPanes.Instance);
            mockOutputWindowPanes.ImplementExpr(owp => owp.Add("StyleCop"), (EnvDTE.OutputWindowPane)mockOutputWindowPane.Instance);

            // Call
            VSWindows_Accessor actual = VSWindows_Accessor.GetInstance(this.serviceProvider);

            // Verify
            Assert.IsNotNull(actual.OutputPane, "OutputPane property was null");
        }
开发者ID:jonthegiant,项目名称:StyleCop,代码行数:17,代码来源:VSWindowsTest.cs

示例4: PackageCommandSetConstructorTest

        public void PackageCommandSetConstructorTest()
        {
            var mockActiveDocument = new Mock<Document>();
            var mockDte = new Mock<DTE>();

            mockDte.ImplementExpr(dte => dte.ActiveDocument, mockActiveDocument.Instance);

            this.mockServiceProvider.ImplementExpr(sp => sp.GetService(typeof(EnvDTE.DTE)), mockDte.Instance);

            PackageCommandSet target = new PackageCommandSet(this.mockServiceProvider.Instance);
            CommandSet innerTarget = new PackageCommandSet(this.mockServiceProvider.Instance);
            Assert.IsNotNull(typeof(PackageCommandSet).GetProperty("CommandList", BindingFlags.NonPublic | BindingFlags.Instance)
                .GetValue(innerTarget),
                "CommandList was not created.");
            Assert.IsNotNull(typeof(PackageCommandSet).GetProperty("ServiceProvider", BindingFlags.NonPublic | BindingFlags.Instance)
                .GetValue(innerTarget),
                "Service provider not stored by the constructor");
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:18,代码来源:PackageCommandSetTest.cs

示例5: PackageCommandSetConstructorTest

        public void PackageCommandSetConstructorTest()
        {
            var mockActiveDocument = new Mock<Document>();
            var mockDte = new Mock<DTE>();

            mockDte.ImplementExpr(dte => dte.ActiveDocument, mockActiveDocument.Instance);

            this.mockServiceProvider.ImplementExpr(sp => sp.GetService(typeof(EnvDTE.DTE)), mockDte.Instance);

            PackageCommandSet target = new PackageCommandSet(this.mockServiceProvider.Instance);
            CommandSet innerTarget = new PackageCommandSet(this.mockServiceProvider.Instance);

            PrivateObject packageCommandSet = new PrivateObject(target, new PrivateType(typeof(PackageCommandSet)));
            PrivateObject commandSet = new PrivateObject(innerTarget, new PrivateType(typeof(CommandSet)));

            Assert.IsNotNull(packageCommandSet.GetFieldOrProperty("CommandList"), "CommandList was not created.");
            Assert.IsNotNull(commandSet.GetFieldOrProperty("ServiceProvider"), "Service provider not stored by the constructor");
        }
开发者ID:kopelli,项目名称:Visual-StyleCop,代码行数:18,代码来源:PackageCommandSetTest.cs

示例6: SetupMockWindow

 private Mock<Window> SetupMockWindow()
 {
     Mock<Windows> mockWindows = new Mock<Windows>();
     Mock<Window> mockWindow = new Mock<Window>();
     mockWindows.ImplementExpr(ws => ws.Item(EnvDTE.Constants.vsWindowKindOutput), (EnvDTE.Window)mockWindow.Instance);
     this.serviceProvider.DTE.Windows = mockWindows.Instance as EnvDTE.Windows;
     return mockWindow;
 }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:8,代码来源:VSWindowsTest.cs

示例7: PrepareServiceProvider

 private IServiceProvider PrepareServiceProvider()
 {
     var mock = new Mock<IServiceProvider>();
     var mockSolution = new Mock<IVsSolution>();
     mock.ImplementExpr(m => m.GetService(typeof(SVsSolution)), mockSolution.Instance as IVsSolution);
     return mock.Instance as IServiceProvider;
 }
开发者ID:kopelli,项目名称:Visual-StyleCop,代码行数:7,代码来源:SolutionListenerTest.cs

示例8: SetupProjectUtilities

        private void SetupProjectUtilities(
            SequenceMock<IEnumerator> mockDocumentEnumerator, 
            Mock<DTE> mockDte, 
            Mock<Documents> mockDocuments, 
            SequenceMock<Document> mockDocument, 
            Mock<Document> mockActiveDocument, 
            string fileName)
        {
            var mockSolution = new Mock<Solution>();
            var mockProjects = new Mock<Projects>();
            var mockProject = new Mock<Project>();
            var mockProjectEnumerator = new SequenceMock<IEnumerator>();

            // var mockEvents = new Mock<EnvDTE.Events>();
            mockDte.ImplementExpr(dte => dte.Solution, mockSolution.Instance);
            mockDte.ImplementExpr(dte => dte.Documents, mockDocuments.Instance);
            mockDte.ImplementExpr(dte => dte.ActiveDocument, mockActiveDocument.Instance);

            // mockDte.ImplementExpr(dte => dte.Events, mockEvents.Instance);
            mockSolution.ImplementExpr(sol => sol.Projects, mockProjects.Instance);
            mockProjects.ImplementExpr(e => e.GetEnumerator(), mockProjectEnumerator.Instance);

            mockProjectEnumerator.AddExpectationExpr(en => en.MoveNext(), true);
            mockProjectEnumerator.AddExpectationExpr(en => en.Current, mockProject.Instance);
            mockProjectEnumerator.AddExpectationExpr(en => en.MoveNext(), false);

            mockProject.ImplementExpr(p => p.Kind, EnvDTE.Constants.vsProjectKindMisc);
            mockProject.ImplementExpr(p => p.ProjectItems, (Func<ProjectItems>)delegate { return null; });

            mockDocuments.ImplementExpr(docs => docs.GetEnumerator(), mockDocumentEnumerator.Instance);

            mockDocumentEnumerator.AddExpectationExpr(docs => docs.MoveNext(), true);
            mockDocumentEnumerator.AddExpectationExpr(docs => docs.Current, mockDocument.Instance);
            mockDocumentEnumerator.AddExpectationExpr(docs => docs.MoveNext(), false);

            mockDocument.AddExpectationExpr(doc => doc.FullName, fileName);
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:37,代码来源:ViolationTaskTest.cs

示例9: OnNavigateToDocNotInProjectTest

        public void OnNavigateToDocNotInProjectTest()
        {
            var mockDocumentEnumerator = new SequenceMock<IEnumerator>();
            var mockDte = new Mock<DTE>();
            var mockDocuments = new Mock<Documents>();
            var mockDocument = new SequenceMock<Document>();
            var mockActiveDocument = new Mock<Document>();
            var mockTextSelection = new SequenceMock<TextSelection>();
            var mockVirtualPoint = new SequenceMock<VirtualPoint>();

            this.SetupProjectUtilities(mockDocumentEnumerator, mockDte, mockDocuments, mockDocument, mockActiveDocument, "DummyFile.txt");
            var mockSecondDocument = new SequenceMock<Document>();
            mockDocumentEnumerator.AddExpectationExpr(docs => docs.MoveNext(), true);
            mockDocumentEnumerator.AddExpectationExpr(docs => docs.Current, mockSecondDocument.Instance);
            mockDocumentEnumerator.AddExpectationExpr(docs => docs.MoveNext(), false);

            mockSecondDocument.AddExpectationExpr(doc => doc.FullName, "DummyFile.txt");

            AnalysisHelper analysisHelper = this.SetCoreNoUI();
            bool eventFired = false;
            var styleCopCore = (StyleCopCore)typeof(AnalysisHelper)
                .GetField("core", BindingFlags.Instance | BindingFlags.NonPublic)
                .GetValue(analysisHelper);
            styleCopCore.OutputGenerated += (sender, args) => { eventFired = true; };

            mockActiveDocument.ImplementExpr(doc => doc.Selection, mockTextSelection.Instance);

            mockTextSelection.ImplementExpr(sel => sel.GotoLine(this.violation.LineNumber, true));
            mockTextSelection.ImplementExpr(sel => sel.ActivePoint, mockVirtualPoint.Instance);

            mockVirtualPoint.ImplementExpr(vp => vp.TryToShow(EnvDTE.vsPaneShowHow.vsPaneShowCentered, 0));

            this.mockServiceProvider.ImplementExpr(sp => sp.GetService(typeof(EnvDTE.DTE)), mockDte.Instance);
            typeof(ProjectUtilities).GetField("serviceProvider", BindingFlags.Static | BindingFlags.NonPublic)
                .SetValue(null, this.mockServiceProvider.Instance);

            // Execute
            typeof(ViolationTask).GetMethod("OnNavigate", BindingFlags.Instance | BindingFlags.NonPublic)
                .Invoke(this.taskUnderTest, new object[] { EventArgs.Empty });

            // Verify the required methods are called to show the violation
            mockTextSelection.Verify();
            mockVirtualPoint.Verify();
            mockDocument.Verify();

            Assert.IsTrue(eventFired, "Core did not fire output event");
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:47,代码来源:ViolationTaskTest.cs

示例10: OnNavigateToDocInProjectTest

        public void OnNavigateToDocInProjectTest()
        {
            var mockDocumentEnumerator = new SequenceMock<IEnumerator>();
            var mockDte = new Mock<DTE>();
            var mockDocuments = new Mock<Documents>();
            var mockDocument = new SequenceMock<Document>();
            var mockActiveDocument = new Mock<Document>();
            var mockTextSelection = new SequenceMock<TextSelection>();
            var mockVirtualPoint = new SequenceMock<VirtualPoint>();

            this.SetupProjectUtilities(mockDocumentEnumerator, mockDte, mockDocuments, mockDocument, mockActiveDocument, this.violation.File);

            mockDocument.AddExpectationExpr(doc => doc.Activate());
            mockDocument.AddExpectationExpr(doc => doc.DTE, (Func<DTE>)delegate { return (EnvDTE.DTE)mockDte.Instance; });

            mockActiveDocument.ImplementExpr(doc => doc.Selection, mockTextSelection.Instance);

            mockTextSelection.ImplementExpr(sel => sel.GotoLine(this.violation.LineNumber, true));
            mockTextSelection.ImplementExpr(sel => sel.ActivePoint, mockVirtualPoint.Instance);

            mockVirtualPoint.ImplementExpr(vp => vp.TryToShow(EnvDTE.vsPaneShowHow.vsPaneShowCentered, 0));

            this.mockServiceProvider.ImplementExpr(sp => sp.GetService(typeof(EnvDTE.DTE)), mockDte.Instance);
            typeof(ProjectUtilities).GetField("serviceProvider", BindingFlags.Static | BindingFlags.NonPublic)
                .SetValue(null, this.mockServiceProvider.Instance);

            // Execute
            typeof(ViolationTask).GetMethod("OnNavigate", BindingFlags.Instance | BindingFlags.NonPublic)
                .Invoke(this.taskUnderTest, new object[] { EventArgs.Empty });

            // Verify the required methods are called to show the violation
            mockTextSelection.Verify();
            mockVirtualPoint.Verify();
            mockDocument.Verify();
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:35,代码来源:ViolationTaskTest.cs

示例11: OnNavigateToDocNotInProjectTest

        public void OnNavigateToDocNotInProjectTest()
        {
            var mockDocumentEnumerator = new SequenceMock<IEnumerator>();
            var mockDte = new Mock<DTE>();
            var mockDocuments = new Mock<Documents>();
            var mockDocument = new SequenceMock<Document>();
            var mockActiveDocument = new Mock<Document>();
            var mockTextSelection = new SequenceMock<TextSelection>();
            var mockVirtualPoint = new SequenceMock<VirtualPoint>();

            this.SetupProjectUtilities(mockDocumentEnumerator, mockDte, mockDocuments, mockDocument, mockActiveDocument, "DummyFile.txt");
            var mockSecondDocument = new SequenceMock<Document>();
            mockDocumentEnumerator.AddExpectationExpr(docs => docs.MoveNext(), true);
            mockDocumentEnumerator.AddExpectationExpr(docs => docs.Current, mockSecondDocument.Instance);
            mockDocumentEnumerator.AddExpectationExpr(docs => docs.MoveNext(), false);

            mockSecondDocument.AddExpectationExpr(doc => doc.FullName, "DummyFile.txt");

            AnalysisHelper_Accessor analysisHelper = this.SetCoreNoUI();
            bool eventFired = false;
            analysisHelper.core.OutputGenerated += (sender, args) => { eventFired = true; };

            mockActiveDocument.ImplementExpr(doc => doc.Selection, mockTextSelection.Instance);

            mockTextSelection.ImplementExpr(sel => sel.GotoLine(this.violation.LineNumber, true));
            mockTextSelection.ImplementExpr(sel => sel.ActivePoint, mockVirtualPoint.Instance);

            mockVirtualPoint.ImplementExpr(vp => vp.TryToShow(EnvDTE.vsPaneShowHow.vsPaneShowCentered, 0));

            this.mockServiceProvider.ImplementExpr(sp => sp.GetService(typeof(EnvDTE.DTE)), mockDte.Instance);
            ProjectUtilities_Accessor.serviceProvider = this.mockServiceProvider.Instance;

            // Execute
            this.taskUnderTest.OnNavigate(EventArgs.Empty);

            // Verify the required methods are called to show the violation
            mockTextSelection.Verify();
            mockVirtualPoint.Verify();
            mockDocument.Verify();

            Assert.IsTrue(eventFired, "Core did not fire output event");
        }
开发者ID:kjata30,项目名称:StyleCop,代码行数:42,代码来源:ViolationTaskTest.cs

示例12: OnNavigateToDocInProjectTest

        public void OnNavigateToDocInProjectTest()
        {
            var mockDocumentEnumerator = new SequenceMock<IEnumerator>();
            var mockDte = new Mock<DTE>();
            var mockDocuments = new Mock<Documents>();
            var mockDocument = new SequenceMock<Document>();
            var mockActiveDocument = new Mock<Document>();
            var mockTextSelection = new SequenceMock<TextSelection>();
            var mockVirtualPoint = new SequenceMock<VirtualPoint>();

            this.SetupProjectUtilities(mockDocumentEnumerator, mockDte, mockDocuments, mockDocument, mockActiveDocument, this.violation.File);

            mockDocument.AddExpectationExpr(doc => doc.Activate());
            mockDocument.AddExpectationExpr(doc => doc.DTE, (Func<DTE>)delegate { return (EnvDTE.DTE)mockDte.Instance; });

            mockActiveDocument.ImplementExpr(doc => doc.Selection, mockTextSelection.Instance);

            mockTextSelection.ImplementExpr(sel => sel.GotoLine(this.violation.LineNumber, true));
            mockTextSelection.ImplementExpr(sel => sel.ActivePoint, mockVirtualPoint.Instance);

            mockVirtualPoint.ImplementExpr(vp => vp.TryToShow(EnvDTE.vsPaneShowHow.vsPaneShowCentered, 0));

            this.mockServiceProvider.ImplementExpr(sp => sp.GetService(typeof(EnvDTE.DTE)), mockDte.Instance);
            ProjectUtilities_Accessor.serviceProvider = this.mockServiceProvider.Instance;

            // Execute
            this.taskUnderTest.OnNavigate(EventArgs.Empty);

            // Verify the required methods are called to show the violation
            mockTextSelection.Verify();
            mockVirtualPoint.Verify();
            mockDocument.Verify();
        }
开发者ID:kjata30,项目名称:StyleCop,代码行数:33,代码来源:ViolationTaskTest.cs

示例13: OnNavigateToDocNotInProjectTest

        public void OnNavigateToDocNotInProjectTest()
        {
            var mockDocumentEnumerator = new SequenceMock<IEnumerator>();
            var mockDte = new Mock<DTE>();
            var mockDocuments = new Mock<Documents>();
            var mockDocument = new SequenceMock<Document>();
            var mockActiveDocument = new Mock<Document>();
            var mockTextSelection = new SequenceMock<TextSelection>();
            var mockVirtualPoint = new SequenceMock<VirtualPoint>();

            this.SetupProjectUtilities(mockDocumentEnumerator, mockDte, mockDocuments, mockDocument, mockActiveDocument, "DummyFile.txt");
            var mockSecondDocument = new SequenceMock<Document>();
            mockDocumentEnumerator.AddExpectationExpr(docs => docs.MoveNext(), true);
            mockDocumentEnumerator.AddExpectationExpr(docs => docs.Current, mockSecondDocument.Instance);
            mockDocumentEnumerator.AddExpectationExpr(docs => docs.MoveNext(), false);

            mockSecondDocument.AddExpectationExpr(doc => doc.FullName, "DummyFile.txt");

            AnalysisHelper analysisHelper = this.SetCoreNoUI();
            bool eventFired = false;

            PrivateObject actual = new PrivateObject(this.package, new PrivateType(typeof(StyleCopVSPackage)));
            actual.SetFieldOrProperty("core", this.package.Core);

            // Register output generated event to test event fired
            this.package.Core.OutputGenerated += (sender, args) => { eventFired = true; };

            mockActiveDocument.ImplementExpr(doc => doc.Selection, mockTextSelection.Instance);

            mockTextSelection.ImplementExpr(sel => sel.GotoLine(this.violation.LineNumber, true));
            mockTextSelection.ImplementExpr(sel => sel.ActivePoint, mockVirtualPoint.Instance);

            mockVirtualPoint.ImplementExpr(vp => vp.TryToShow(EnvDTE.vsPaneShowHow.vsPaneShowCentered, 0));

            this.mockServiceProvider.ImplementExpr(sp => sp.GetService(typeof(EnvDTE.DTE)), mockDte.Instance);

            // Use private type to set static private field
            PrivateType privateProjectUtilities = new PrivateType(typeof(ProjectUtilities));
            privateProjectUtilities.SetStaticFieldOrProperty("serviceProvider", this.mockServiceProvider.Instance);

            // Execute
            PrivateObject taskUnderTestPrivateObject = new PrivateObject(this.taskUnderTest, new PrivateType(typeof(ViolationTask)));
            taskUnderTestPrivateObject.Invoke("OnNavigate", EventArgs.Empty);

            // Verify the required methods are called to show the violation
            mockTextSelection.Verify();
            mockVirtualPoint.Verify();
            mockDocument.Verify();

            Assert.IsTrue(eventFired, "Core did not fire output event");
        }
开发者ID:kopelli,项目名称:Visual-StyleCop,代码行数:51,代码来源:ViolationTaskTest.cs

示例14: OnNavigateToDocInProjectTest

        public void OnNavigateToDocInProjectTest()
        {
            var mockDocumentEnumerator = new SequenceMock<IEnumerator>();
            var mockDte = new Mock<DTE>();
            var mockDocuments = new Mock<Documents>();
            var mockDocument = new SequenceMock<Document>();
            var mockActiveDocument = new Mock<Document>();
            var mockTextSelection = new SequenceMock<TextSelection>();
            var mockVirtualPoint = new SequenceMock<VirtualPoint>();

            this.SetupProjectUtilities(mockDocumentEnumerator, mockDte, mockDocuments, mockDocument, mockActiveDocument, this.violation.File);

            mockDocument.AddExpectationExpr(doc => doc.Activate());
            mockDocument.AddExpectationExpr(doc => doc.DTE, (Func<DTE>)delegate { return (EnvDTE.DTE)mockDte.Instance; });

            mockActiveDocument.ImplementExpr(doc => doc.Selection, mockTextSelection.Instance);

            mockTextSelection.ImplementExpr(sel => sel.GotoLine(this.violation.LineNumber, true));
            mockTextSelection.ImplementExpr(sel => sel.ActivePoint, mockVirtualPoint.Instance);

            mockVirtualPoint.ImplementExpr(vp => vp.TryToShow(EnvDTE.vsPaneShowHow.vsPaneShowCentered, 0));

            this.mockServiceProvider.ImplementExpr(sp => sp.GetService(typeof(EnvDTE.DTE)), mockDte.Instance);

            this.mockServiceProvider.ImplementExpr(sp => sp.GetService(typeof(EnvDTE.DTE)), mockDte.Instance);
            this.mockServiceProvider.ImplementExpr(sp => sp.GetService(typeof(SVsSolutionBuildManager)), new MockSolutionBuildManager());

            // Use private type to set static private field
            PrivateType privateProjectUtilities = new PrivateType(typeof(ProjectUtilities));
            privateProjectUtilities.SetStaticFieldOrProperty("serviceProvider", this.mockServiceProvider.Instance);

            // Execute
            PrivateObject taskUnderTestPrivateObject = new PrivateObject(this.taskUnderTest, new PrivateType(typeof(ViolationTask)));
            taskUnderTestPrivateObject.Invoke("OnNavigate", EventArgs.Empty);

            // Verify the required methods are called to show the violation
            mockTextSelection.Verify();
            mockVirtualPoint.Verify();
            mockDocument.Verify();
        }
开发者ID:kopelli,项目名称:Visual-StyleCop,代码行数:40,代码来源:ViolationTaskTest.cs

示例15: OutputPanePropertyTest

        public void OutputPanePropertyTest()
        {
            try
            {
                // Setup
                Mock<Window> mockWindow = this.SetupMockWindow();
                Mock<OutputWindow> mockOutputWindow = new Mock<OutputWindow>();
                mockWindow.ImplementExpr(w => w.Object, (EnvDTE.OutputWindow)mockOutputWindow.Instance);
                Mock<OutputWindowPane> mockOutputWindowPane = new Mock<OutputWindowPane>();
                Mock<OutputWindowPanes> mockOutputWindowPanes = new Mock<OutputWindowPanes>();
                mockOutputWindow.ImplementExpr(ow => ow.OutputWindowPanes, (EnvDTE.OutputWindowPanes)mockOutputWindowPanes.Instance);
                mockOutputWindowPanes.ImplementExpr(owp => owp.Add("StyleCop"), (EnvDTE.OutputWindowPane)mockOutputWindowPane.Instance);

                // Call
                VSWindows actual = VSWindows.GetInstance(this.serviceProvider);

                // Verify
                Assert.IsNotNull(actual.OutputPane, "OutputPane property was null");
            }
            catch (Exception ex)
            {
                // Use try catch to test a workaround on CI build (AppVeyor)
                Console.WriteLine(ex.Message);
            }
        }
开发者ID:Visual-Stylecop,项目名称:Visual-StyleCop,代码行数:25,代码来源:VSWindowsTest.cs


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