Esempio n. 1
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 cmd = new PublishSProcCommand(_appShell, _pss);

            cmd.TryHandleCommand(null, RPackageCommandId.icmdPublishSProc, false, 0, IntPtr.Zero, IntPtr.Zero).Should().BeTrue();
            _appShell.Received().ShowErrorMessage(Resources.SqlPublishDialog_NoSProcFiles);
        }