예제 #1
0
        private static ProjectDesignerService CreateInstance(IUnconfiguredProjectVsServices?projectVsServices, IVsProjectDesignerPageService?vsProjectDesignerPageService)
        {
            projectVsServices ??= IUnconfiguredProjectVsServicesFactory.Create();
            vsProjectDesignerPageService ??= IVsProjectDesignerPageServiceFactory.Create();

            return(new ProjectDesignerService(projectVsServices, vsProjectDesignerPageService));
        }
        public void Constructor_NullAsProjectVsServices_ThrowsArgumentNull()
        {
            var vsProjectDesignerPageService = IVsProjectDesignerPageServiceFactory.Create();

            Assert.Throws <ArgumentNullException>("projectVsServices", () => {
                new ProjectDesignerService((IUnconfiguredProjectVsServices)null, vsProjectDesignerPageService);
            });
        }
        public void ShowProjectDesignerAsync_WhenSupportsProjectDesignerFalse_ThrowsInvalidOperation()
        {
            var vsProjectDesignerPageService = IVsProjectDesignerPageServiceFactory.ImplementIsProjectDesignerSupported(() => false);

            var designerService = CreateInstance(vsProjectDesignerPageService);

            Assert.ThrowsAsync <InvalidOperationException>(designerService.ShowProjectDesignerAsync);
        }
예제 #4
0
        public void SupportsProjectDesigner_ReturnsResultIsProjectDesignerSupported(bool supportsProjectDesigner)
        {
            var vsProjectDesignerPageService = IVsProjectDesignerPageServiceFactory.ImplementIsProjectDesignerSupported(() => supportsProjectDesigner);

            var designerService = CreateInstance(vsProjectDesignerPageService);

            var result = designerService.SupportsProjectDesigner;

            Assert.Equal(supportsProjectDesigner, result);
        }
        public async Task ShowProjectDesignerAsync_WhenProjectDesignerEditorReturnsHResult_Throws()
        {
            var vsProjectDesignerPageService = IVsProjectDesignerPageServiceFactory.ImplementIsProjectDesignerSupported(() => true);

            var hierarchy = IVsHierarchyFactory.Create();

            hierarchy.ImplementGetGuid(VsHierarchyPropID.ProjectDesignerEditor, VSConstants.E_FAIL);

            var projectVsServices = IUnconfiguredProjectVsServicesFactory.Implement(() => hierarchy);

            var designerService = CreateInstance(projectVsServices, vsProjectDesignerPageService);

            await Assert.ThrowsAsync <COMException>(designerService.ShowProjectDesignerAsync);
        }
        public Task ShowProjectDesignerAsync_WhenOpenedInExternalEditor_DoesNotAttemptToShowWindow()
        {   // OpenItemWithSpecific returns null frame when opened in external editor

            var vsProjectDesignerPageService = IVsProjectDesignerPageServiceFactory.ImplementIsProjectDesignerSupported(() => true);

            var editorGuid = Guid.NewGuid();

            var hierarchy = IVsHierarchyFactory.Create();
            hierarchy.ImplementGetGuid(VsHierarchyPropID.ProjectDesignerEditor, result: editorGuid);

            var project = (IVsProject4)hierarchy;
            project.ImplementOpenItemWithSpecific(editorGuid, VSConstants.LOGVIEWID_Primary, (IVsWindowFrame?)null);

            var projectVsServices = IUnconfiguredProjectVsServicesFactory.Implement(() => hierarchy, () => project);

            var designerService = CreateInstance(projectVsServices, vsProjectDesignerPageService);

            return designerService.ShowProjectDesignerAsync();
        }
        public async Task ShowProjectDesignerAsync_WhenOpenItemWithSpecificEditorReturnsHResult_Throws()
        {
            var vsProjectDesignerPageService = IVsProjectDesignerPageServiceFactory.ImplementIsProjectDesignerSupported(() => true);

            var editorGuid = Guid.NewGuid();

            var hierarchy = IVsHierarchyFactory.Create();

            hierarchy.ImplementGetGuid(VsHierarchyPropID.ProjectDesignerEditor, result: editorGuid);

            var project = (IVsProject4)hierarchy;

            project.ImplementOpenItemWithSpecific(editorGuid, VSConstants.LOGVIEWID_Primary, VSConstants.E_FAIL);

            var projectVsServices = IUnconfiguredProjectVsServicesFactory.Implement(() => hierarchy, () => project);

            var designerService = CreateInstance(projectVsServices, vsProjectDesignerPageService);

            await Assert.ThrowsAsync <COMException>(designerService.ShowProjectDesignerAsync);
        }
        public async Task ShowProjectDesignerAsync_WhenOpenedInInternalEditor_ShowsWindow()
        {
            var vsProjectDesignerPageService = IVsProjectDesignerPageServiceFactory.ImplementIsProjectDesignerSupported(() => true);

            var editorGuid = Guid.NewGuid();

            var hierarchy = IVsHierarchyFactory.Create();
            hierarchy.ImplementGetGuid(VsHierarchyPropID.ProjectDesignerEditor, result: editorGuid);
            var project = (IVsProject4)hierarchy;

            int callCount = 0;
            var frame = IVsWindowFrameFactory.ImplementShow(() => { callCount++; return 0; });
            project.ImplementOpenItemWithSpecific(editorGuid, VSConstants.LOGVIEWID_Primary, frame);

            var projectVsServices = IUnconfiguredProjectVsServicesFactory.Implement(() => hierarchy, () => project);

            var designerService = CreateInstance(projectVsServices, vsProjectDesignerPageService);

            await designerService.ShowProjectDesignerAsync();

            Assert.Equal(1, callCount);
        }