Exemple #1
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that relies on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            IServiceContainer container = this;

            container.AddService(typeof(TLanguageService), new TLanguageService(), true);

            foreach (var projectFactory in CreateProjectFactories())
            {
                RegisterProjectFactory(projectFactory);
            }

            foreach (var projectFileGenerator in CreateProjectFileGenerators())
            {
                RegisterProjectFileGenerator(projectFileGenerator);
            }

            foreach (var editorFactory in CreateEditorFactories())
            {
                RegisterEditorFactory(editorFactory);
            }

            var menuCommandService = (IMenuCommandService)GetService(typeof(IMenuCommandService));

            foreach (var commmand in CreateMenuCommands())
            {
                menuCommandService.AddCommand(commmand);
            }

            var settings = VsAppShell.Current.GetService <IRSettings>();
            var dte      = VsAppShell.Current.GetService <DTE2>(typeof(DTE));

            _toolbar = new RToolbar(dte, settings);
            _toolbar.Show();
        }
Exemple #2
0
        public void Visibility() {
            var settings = Substitute.For<IRToolsSettings>();
            // NSub does not work with dynamic, see "https://github.com/nsubstitute/NSubstitute/issues/143"
            var dte = new DteMock();
            var cbs = Substitute.For<CommandBars.CommandBars>();
            dte.CommandBars = cbs;

            var cb = Substitute.For<CommandBar>();
            cbs["R Toolbar"].Returns(cb);
            var tb = new RToolbar(dte, settings);
            tb.Show();
            cb.Visible.Should().BeFalse();

            settings.ShowRToolbar.Returns(true);
            tb.Show();
            cb.Visible.Should().BeTrue();

            tb.SaveState();
            settings.ShowRToolbar.Should().BeTrue();

            cb.Visible = false;
            tb.SaveState();
            settings.ShowRToolbar.Should().BeFalse();
        }