Inheritance: ICommandGroupHandler
Esempio n. 1
0
        public void PublishSProcCommandHandle01() {
            _pss.GetSelectedProject<IVsHierarchy>().Returns((IVsHierarchy)null);

            _pss.GetProjectFiles(null).ReturnsForAnyArgs(new string[] { "file.r" });
            var hier = Substitute.For<IVsHierarchy>();

            object ext;
            hier.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ExtObject, out ext).Returns((c) => {
                c[2] = Substitute.For<EnvDTE.Project>();
                return VSConstants.S_OK;
            });
            _pss.GetSelectedProject<IVsHierarchy>().Returns(hier);

            var servicesProvider = Substitute.For<IDacPackageServicesProvider>();

            var cmd = new PublishSProcCommand(_appShell, _pss, servicesProvider, Substitute.For<ISettingsStorage>());
            cmd.TryHandleCommand(null, RPackageCommandId.icmdPublishSProc, false, 0, IntPtr.Zero, IntPtr.Zero).Should().BeTrue();
            //_appShell.Received().ShowErrorMessage(Resources.SqlPublishDialog_NoDbProject);
        }
Esempio n. 2
0
        public void PublishSProcCommandHandle02() {
            var project = Substitute.For<EnvDTE.Project>();
            project.FileName.Returns("db.sqlproj");

            _pss.GetProjectFiles(null).ReturnsForAnyArgs(new string[] { "file.r" });

            object ext;
            var hier = Substitute.For<IVsHierarchy>();
            hier.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ExtObject, out ext).Returns((c) => {
                c[2] = project;
                return VSConstants.S_OK;
            });
            _pss.GetSelectedProject<IVsHierarchy>().Returns(hier);

            var sol = Substitute.For<EnvDTE.Solution>();
            var projects = Substitute.For<EnvDTE.Projects>();
            projects.GetEnumerator().Returns((new EnvDTE.Project[] { project }).GetEnumerator());
            sol.Projects.Returns(projects);
            _pss.GetSolution().Returns(sol);

            var servicesProvider = Substitute.For<IDacPackageServicesProvider>();

            var cmd = new PublishSProcCommand(_appShell, _pss, servicesProvider, Substitute.For<ISettingsStorage>());
            cmd.TryHandleCommand(null, RPackageCommandId.icmdPublishSProc, false, 0, IntPtr.Zero, IntPtr.Zero).Should().BeTrue();
            _appShell.Received().ShowErrorMessage(Resources.SqlPublishDialog_NoSProcFiles);
        }
Esempio n. 3
0
        public void PublishSProcCommandStatus() {
            var servicesProvider = Substitute.For<IDacPackageServicesProvider>();

            var cmd = new PublishSProcCommand(_appShell, _pss, servicesProvider, Substitute.For<ISettingsStorage>());
            cmd.GetCommandStatus(null, 0, true, null, CommandStatus.NotSupported).Should().Be(CommandStatusResult.Unhandled);
            cmd.GetCommandStatus(null, RPackageCommandId.icmdPublishSProc, true, null, CommandStatus.NotSupported)
                .Should().Be(new CommandStatusResult(true, null, CommandStatus.Enabled | CommandStatus.Supported));
            cmd.TryHandleCommand(null, 0, false, 0, IntPtr.Zero, IntPtr.Zero).Should().BeFalse();
        }