Пример #1
0
        public void TestMultipleFailures()
        {
            UIThreadInvoker.Invoke((ThreadInvoker) delegate()
            {
                //Get the global service provider and the dte
                IServiceProvider sp = VsIdeTestHostContext.ServiceProvider;
                DTE dte             = (DTE)sp.GetService(typeof(DTE));

                string mainProjFilename = CreateTempFileOnDisk(@"
			                
								<Project DefaultTargets=`Build`  xmlns=`msbuildnamespace`>
									<PropertyGroup>
										<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
									</PropertyGroup>
									<ItemGroup>        
										<AppConfigFileDestination Include=`$(OutDir)$(TargetFileName).config`/>
									</ItemGroup>   
									<Import Project=`$(MSBuildBinPath)\Microsoft.CSharp.targets`/>
							   </Project>

							"                            );
                try
                {
                    ProjectSecurityChecker projectSecurityChecker = new ProjectSecurityChecker(sp, mainProjFilename);
                    string errorMessage;
                    bool result = projectSecurityChecker.IsProjectSafeAtLoadTime(out errorMessage);

                    Assert.IsFalse(result, "A project was considered safe containing redefined safe properties and safe items!");

                    Assert.IsTrue(errorMessage.Contains("1:") && errorMessage.Contains("2:"), "The error string returning from a project with multiple failures should contain the listed failures");
                }
                finally
                {
                    File.Delete(mainProjFilename);
                }
            });
        }
Пример #2
0
        public void TestMultipleFailures()
        {
            UIThreadInvoker.Invoke((ThreadInvoker)delegate()
            {
                //Get the global service provider and the dte
                IServiceProvider sp = VsIdeTestHostContext.ServiceProvider;
                DTE dte = (DTE)sp.GetService(typeof(DTE));

                string mainProjFilename = CreateTempFileOnDisk(@"

                                <Project DefaultTargets=`Build`  xmlns=`msbuildnamespace`>
                                    <PropertyGroup>
                                        <BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
                                    </PropertyGroup>
                                    <ItemGroup>
                                        <AppConfigFileDestination Include=`$(OutDir)$(TargetFileName).config`/>
                                    </ItemGroup>
                                    <Import Project=`$(MSBuildBinPath)\Microsoft.CSharp.targets`/>
                               </Project>

                            ");
                try
                {
                    ProjectSecurityChecker projectSecurityChecker = new ProjectSecurityChecker(sp, mainProjFilename);
                    string errorMessage;
                    bool result = projectSecurityChecker.IsProjectSafeAtLoadTime(out errorMessage);

                    Assert.IsFalse(result, "A project was considered safe containing redefined safe properties and safe items!");

                    Assert.IsTrue(errorMessage.Contains("1:") && errorMessage.Contains("2:"), "The error string returning from a project with multiple failures should contain the listed failures");
                }
                finally
                {
                    File.Delete(mainProjFilename);
                }
            });
        }