public void CloseTest()
        {
            ResX_AggregatorPackage package = new ResX_AggregatorPackage();

            EditorFactory editorFactory = new EditorFactory(package);
            Assert.AreEqual(VSConstants.S_OK, editorFactory.Close(), "Close did no return S_OK");
        }
Example #2
0
        public void SetSite()
        {
            // Create the package
            IVsPackage package = new ResX_AggregatorPackage() as IVsPackage;
            Assert.IsNotNull(package, "The object does not implement IVsPackage");

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

            // Add site support to register editor factory
            BaseMock registerEditor = ResX_Aggregator_UnitTests.EditorTests.RegisterEditorsServiceMock.GetRegisterEditorsInstance();
            serviceProvider.AddService(typeof(SVsRegisterEditors), registerEditor, false);

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

            // Unsite the package
            Assert.AreEqual(0, package.SetSite(null), "SetSite(null) did not return S_OK");
        }
        public void CheckLogicalView()
        {
            ResX_AggregatorPackage package = new ResX_AggregatorPackage();

            //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));
        }
        public void CreateEditorInstance()
        {
            ResX_AggregatorPackage package = new ResX_AggregatorPackage();

            //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));
        }
        public void SetSite()
        {
            ResX_AggregatorPackage package = new ResX_AggregatorPackage();

            //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");
        }
 public void IsIVsEditorFactory()
 {
     ResX_AggregatorPackage package = new ResX_AggregatorPackage();
     EditorFactory editorFactory = new EditorFactory(package);
     Assert.IsNotNull(editorFactory as IVsEditorFactory, "The object does not implement IVsEditorFactory");
 }
        public void IsIDisposableTest()
        {
            ResX_AggregatorPackage package = new ResX_AggregatorPackage();

            using (EditorFactory editorFactory = new EditorFactory(package))
            {
                Assert.IsNotNull(editorFactory as IDisposable, "The object does not implement IDisposable interface");
            }
        }
        public void DisposeTest()
        {
            ResX_AggregatorPackage package = new ResX_AggregatorPackage();

            EditorFactory editorFactory = new EditorFactory(package);
            editorFactory.Dispose();
        }
        public void DisposeDisposableMembersTest()
        {
            ResX_AggregatorPackage package = new ResX_AggregatorPackage();

            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");
        }
        public void CreateInstance()
        {
            ResX_AggregatorPackage package = new ResX_AggregatorPackage();

            EditorFactory editorFactory = new EditorFactory(package);
            Assert.IsNotNull(editorFactory, "Failed to initialize new instance of EditorFactory.");
        }
Example #11
0
        /// <summary>
        /// Initialization routine for the Editor. Loads the list of properties for the resx-aggregator document 
        /// which will show up in the properties window 
        /// </summary>
        /// <param name="package"></param>
        private void PrivateInit(ResX_AggregatorPackage package)
        {
            myPackage = package;
            loading = false;
            gettingCheckoutStatus = false;
            trackSel = null;

            Control.CheckForIllegalCrossThreadCalls = false;
            // Create an ArrayList to store the objects that can be selected
            ArrayList listObjects = new ArrayList();

            // Create the object that will show the document's properties
            // on the properties window.
            EditorProperties prop = new EditorProperties(this);
            listObjects.Add(prop);

            // Create the SelectionContainer object.
            selContainer = new Microsoft.VisualStudio.Shell.SelectionContainer(true, false);
            selContainer.SelectableObjects = listObjects;
            selContainer.SelectedObjects = listObjects;

            // Create and initialize the editor

            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EditorPane));
            this.editorControl = new MyEditor();

            resources.ApplyResources(this.editorControl, "editorControl", CultureInfo.CurrentUICulture);
            // Event handlers for macro recording.
            this.editorControl.RichTextBoxControl.TextChanged += new System.EventHandler(this.OnTextChange);
            this.editorControl.RichTextBoxControl.MouseDown += new MouseEventHandler(this.OnMouseClick);
            this.editorControl.RichTextBoxControl.SelectionChanged += new EventHandler(this.OnSelectionChanged);
            this.editorControl.RichTextBoxControl.KeyDown += new KeyEventHandler(this.OnKeyDown);
            
            // Handle Focus event
            this.editorControl.RichTextBoxControl.GotFocus += new EventHandler(this.OnGotFocus);
            
            // Call the helper function that will do all of the command setup work
            setupCommands();
        }
Example #12
0
 /// <summary>
 /// Constructor that calls the Microsoft.VisualStudio.Shell.WindowPane constructor then
 /// our initialization functions.
 /// </summary>
 /// <param name="package">Our Package instance.</param>
 public EditorPane(ResX_AggregatorPackage package)
     : base(null)
 {
     PrivateInit(package);
 }
        public EditorFactory(ResX_AggregatorPackage package)
        {
            Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering {0} constructor", this.ToString()));

            this.editorPackage = package;
        }
Example #14
0
 public void IsIVsPackage()
 {
     ResX_AggregatorPackage package = new ResX_AggregatorPackage();
     Assert.IsNotNull(package as IVsPackage, "The object does not implement IVsPackage");
 }
Example #15
0
 public void CreateInstance()
 {
     ResX_AggregatorPackage package = new ResX_AggregatorPackage();
 }