Esempio n. 1
0
        public static IVsSolutionBuildManager2 Create(
            IVsUpdateSolutionEvents?solutionEventsListener = null,
            IVsHierarchy?hierarchyToBuild = null,
            bool isBuilding  = false,
            bool cancelBuild = false)
        {
            var buildManager = new Mock <IVsSolutionBuildManager2>();

            solutionEventsListener ??= IVsUpdateSolutionEventsFactory.Create();
            hierarchyToBuild ??= IVsHierarchyFactory.Create();

            int isBusy = isBuilding ? 1 : 0;

            buildManager.Setup(b => b.QueryBuildManagerBusy(out isBusy))
            .Returns(VSConstants.S_OK);

            if (hierarchyToBuild != null)
            {
                int onBuildStartedWithReturn()
                {
                    solutionEventsListener !.UpdateSolution_Begin(It.IsAny <int>());

                    if (cancelBuild)
                    {
                        solutionEventsListener.UpdateSolution_Cancel();
                    }
                    else
                    {
                        solutionEventsListener.UpdateSolution_Done(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>());
                    }

                    return(VSConstants.S_OK);
                }

                uint dwFlags = (uint)(VSSOLNBUILDUPDATEFLAGS.SBF_SUPPRESS_SAVEBEFOREBUILD_QUERY | VSSOLNBUILDUPDATEFLAGS.SBF_OPERATION_BUILD);
                buildManager.Setup(b => b.StartSimpleUpdateProjectConfiguration(hierarchyToBuild, It.IsAny <IVsHierarchy>(), It.IsAny <string>(), dwFlags, It.IsAny <uint>(), It.IsAny <int>()))
                .Returns(onBuildStartedWithReturn);
            }

            return(buildManager.Object);
        }
        public static IVsSolutionBuildManager2 Create(
            IVsUpdateSolutionEvents?solutionEventsListener = null,
            IVsHierarchy?hierarchyToBuild = null,
            bool isBuilding  = false,
            bool cancelBuild = false)
        {
            var buildManager = new Mock <IVsSolutionBuildManager2>();

            solutionEventsListener ??= IVsUpdateSolutionEventsFactory.Create();
            hierarchyToBuild ??= IVsHierarchyFactory.Create();

            int isBusy = isBuilding ? 1 : 0;

            buildManager.Setup(b => b.QueryBuildManagerBusy(out isBusy))
            .Returns(VSConstants.S_OK);

            if (hierarchyToBuild != null)
            {
                int onBuildStartedWithReturn()
                {
                    solutionEventsListener.UpdateSolution_Begin(It.IsAny <int>());

                    if (cancelBuild)
                    {
                        solutionEventsListener.UpdateSolution_Cancel();
                    }
                    else
                    {
                        solutionEventsListener.UpdateSolution_Done(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>());
                    }

                    return(VSConstants.S_OK);
                }

                buildManager.Setup(b => b.StartUpdateSpecificProjectConfigurations(It.IsAny <uint>(), It.IsAny <IVsHierarchy[]>(), It.IsAny <IVsCfg[]>(), It.IsAny <uint[]>(), It.IsAny <uint[]>(), It.IsAny <uint[]>(), It.IsAny <uint>(), It.IsAny <int>()))
                .Returns(onBuildStartedWithReturn);
            }

            return(buildManager.Object);
        }