Exemple #1
0
        public void CreateEditorInstance()
        {
            VisualStudioHaskellPackage package = new VisualStudioHaskellPackage();

            //Create the editor factory
            EditorFactory editorFactory = new EditorFactory(package);

            // Create a basic service provider
            OleServiceProvider serviceProvider = OleServiceProvider.CreateOleServiceProviderWithBasicServices();

            serviceProvider.AddService(typeof(SLocalRegistry), (ILocalRegistry)LocalRegistryServiceMock.GetILocalRegistryInstance(), true);

            // Site the editor factory
            Assert.AreEqual(0, editorFactory.SetSite(serviceProvider), "SetSite did not return S_OK");

            IntPtr ppunkDocView;
            IntPtr ppunkDocData;
            string pbstrEditorCaption = String.Empty;
            Guid   pguidCmdUI         = Guid.Empty;
            int    pgrfCDW            = 0;

            Assert.AreEqual(VSConstants.S_OK, editorFactory.CreateEditorInstance(VSConstants.CEF_OPENFILE,
                                                                                 null, null, null, 0, IntPtr.Zero, out ppunkDocView, out ppunkDocData, out pbstrEditorCaption,
                                                                                 out pguidCmdUI, out pgrfCDW));
        }
Exemple #2
0
        public void CreateEditorInstanceTest()
        {
            //Create the editor factory
            EditorFactory targetFactory = editorFactory;

            // Create a basic service provider
            OleServiceProvider serviceProvider = OleServiceProvider.CreateOleServiceProviderWithBasicServices();

            AddBasicSiteSupport(serviceProvider);

            // Site the editor factory
            Assert.AreEqual(0, targetFactory.SetSite(serviceProvider), "SetSite did not return S_OK");

            IntPtr ppunkDocView;
            IntPtr ppunkDocData;
            string pbstrEditorCaption = String.Empty;
            Guid   pguidCmdUI         = Guid.Empty;
            int    pgrfCDW            = 0;
            uint   cef_option         = VSConstants.CEF_OPENFILE;

            int actual_result = targetFactory.CreateEditorInstance(cef_option, null, null, null,
                                                                   0, IntPtr.Zero, out ppunkDocView, out ppunkDocData, out pbstrEditorCaption, out pguidCmdUI, out pgrfCDW);

            Assert.AreEqual(VSConstants.S_OK, actual_result);
        }
Exemple #3
0
        public void SetSite()
        {
            //Create the editor factory
            EditorFactory editorFactory = new EditorFactory();

            // Create a basic service provider
            OleServiceProvider serviceProvider = OleServiceProvider.CreateOleServiceProviderWithBasicServices();

            // Site the editor factory
            Assert.AreEqual(0, editorFactory.SetSite(serviceProvider), "SetSite did not return S_OK");
        }
Exemple #4
0
        public void SetSite()
        {
            VisualStudioHaskellPackage package = new VisualStudioHaskellPackage();

            //Create the editor factory
            EditorFactory editorFactory = new EditorFactory(package);

            // Create a basic service provider
            OleServiceProvider serviceProvider = OleServiceProvider.CreateOleServiceProviderWithBasicServices();

            // Site the editor factory
            Assert.AreEqual(0, editorFactory.SetSite(serviceProvider), "SetSite did not return S_OK");
        }
Exemple #5
0
        public void DisposeDisposableMembersTest()
        {
            VisualStudioHaskellPackage package = new VisualStudioHaskellPackage();

            EditorFactory      editorFactory   = new EditorFactory(package);
            OleServiceProvider serviceProvider = OleServiceProvider.CreateOleServiceProviderWithBasicServices();

            editorFactory.SetSite(serviceProvider);
            object service = editorFactory.GetService(typeof(IProfferService));

            Assert.IsNotNull(service);
            editorFactory.Dispose(); //service provider contains no services after this call
            service = editorFactory.GetService(typeof(IProfferService));
            Assert.IsNull(service, "serviceprovider has not beed disposed as expected");
        }
Exemple #6
0
        public void CheckLogicalView()
        {
            VisualStudioHaskellPackage package = new VisualStudioHaskellPackage();

            //Create the editor factory
            EditorFactory editorFactory = new EditorFactory(package);

            // Create a basic service provider
            OleServiceProvider serviceProvider = OleServiceProvider.CreateOleServiceProviderWithBasicServices();

            serviceProvider.AddService(typeof(SLocalRegistry), (ILocalRegistry)LocalRegistryServiceMock.GetILocalRegistryInstance(), true);

            // Site the editor factory
            Assert.AreEqual(0, editorFactory.SetSite(serviceProvider), "SetSite did not return S_OK");

            IntPtr ppunkDocView;
            IntPtr ppunkDocData;
            string pbstrEditorCaption = String.Empty;
            Guid   pguidCmdUI         = Guid.Empty;
            int    pgrfCDW            = 0;

            Assert.AreEqual(VSConstants.S_OK, editorFactory.CreateEditorInstance(VSConstants.CEF_OPENFILE,
                                                                                 null, null, null, 0, IntPtr.Zero, out ppunkDocView, out ppunkDocData, out pbstrEditorCaption,
                                                                                 out pguidCmdUI, out pgrfCDW)); //check for successfull creation of editor instance

            string bstrPhysicalView   = string.Empty;
            Guid   refGuidLogicalView = VSConstants.LOGVIEWID_Debugging;

            Assert.AreEqual(VSConstants.E_NOTIMPL, editorFactory.MapLogicalView(ref refGuidLogicalView, out bstrPhysicalView));

            refGuidLogicalView = VSConstants.LOGVIEWID_Code;
            Assert.AreEqual(VSConstants.E_NOTIMPL, editorFactory.MapLogicalView(ref refGuidLogicalView, out bstrPhysicalView));

            refGuidLogicalView = VSConstants.LOGVIEWID_TextView;
            Assert.AreEqual(VSConstants.S_OK, editorFactory.MapLogicalView(ref refGuidLogicalView, out bstrPhysicalView));

            refGuidLogicalView = VSConstants.LOGVIEWID_UserChooseView;
            Assert.AreEqual(VSConstants.E_NOTIMPL, editorFactory.MapLogicalView(ref refGuidLogicalView, out bstrPhysicalView));

            refGuidLogicalView = VSConstants.LOGVIEWID_Primary;
            Assert.AreEqual(VSConstants.S_OK, editorFactory.MapLogicalView(ref refGuidLogicalView, out bstrPhysicalView));
        }
Exemple #7
0
        public void CreateEditorInstanceWithBadInputsTest()
        {
            //Create the editor factory
            EditorFactory targetFactory = editorFactory;

            // Create a basic service provider
            OleServiceProvider serviceProvider = OleServiceProvider.CreateOleServiceProviderWithBasicServices();

            // Site the editor factory
            Assert.AreEqual(0, targetFactory.SetSite(serviceProvider), "SetSite did not return S_OK");

            IntPtr ppunkDocView;
            IntPtr ppunkDocData;
            string pbstrEditorCaption = String.Empty;
            Guid   pguidCmdUI         = Guid.Empty;
            int    pgrfCDW            = 0;
            uint   cef_option         = 0;

            // test scenario with invalid CEF_* option
            IntPtr punkDocDataExisting = IntPtr.Zero;

            int actual_result = targetFactory.CreateEditorInstance(cef_option, null, null, null,
                                                                   0, punkDocDataExisting, out ppunkDocView, out ppunkDocData, out pbstrEditorCaption, out pguidCmdUI, out pgrfCDW);

            Assert.AreEqual(VSConstants.E_INVALIDARG, actual_result, "CreateEditorInstance() can not process invalid CEF_* arguments");

            ppunkDocView       = IntPtr.Zero;
            ppunkDocData       = IntPtr.Zero;
            pbstrEditorCaption = String.Empty;
            pguidCmdUI         = Guid.Empty;
            pgrfCDW            = 0;
            cef_option         = VSConstants.CEF_OPENFILE;

            // test scenario with not-null punkDocDataExisting parameter value
            punkDocDataExisting = new IntPtr(Int32.MaxValue);

            actual_result = targetFactory.CreateEditorInstance(cef_option, null, null, null,
                                                               0, punkDocDataExisting, out ppunkDocView, out ppunkDocData, out pbstrEditorCaption, out pguidCmdUI, out pgrfCDW);
            Assert.AreEqual(VSConstants.VS_E_INCOMPATIBLEDOCDATA, actual_result, "CreateEditorInstance() can not process incompatible document data argument");
        }