public void TestPackageInstall() { using (NuGetPackageTestHelper nugetHelper = new NuGetPackageTestHelper()) { //nugetHelper.vsProjectManager.CloseAllSkus(); //close any stale instances. //Launch appropriate version of VS and SKU nugetHelper.vsProjectManager.LaunchVS(VSVersion.VS2012, VSSKU.VSU); //Create project with desired template and framework. nugetHelper.vsProjectManager.CreateProject(ProjectTemplates.ConsoleAppCSharp, ProjectTargetFrameworks.Net45, projName, solnPath); //Analyze package and verify package installtion string analysisOutput = nugetHelper.nuGetPackageManager.AnalyzePackage(packagePath); TestContext.WriteLine("Output from Package analysis : {0}", analysisOutput); string packageInstallOutput = string.Empty; Assert.IsTrue(nugetHelper.nuGetPackageManager.InstallPackage(packagePath, out packageInstallOutput), "Install package failed."); TestContext.WriteLine("Output from Package Install : {0} {1}", Environment.NewLine, packageInstallOutput); Assert.IsTrue(nugetHelper.VerifyPackageInstallation(packagePath), "Install verification failed"); } }
public void TestIndividualPackageVerifiers() { using (NuGetPackageTestHelper nugetHelper = new NuGetPackageTestHelper()) { //nugetHelper.vsProjectManager.CloseAllSkus(); //close any stale instances. //Launch appropriate version of VS and SKU nugetHelper.vsProjectManager.LaunchVS(VSVersion.VS2012, VSSKU.VSU); //Create project with desired template and framework. nugetHelper.vsProjectManager.CreateProject(ProjectTemplates.ConsoleAppCSharp, ProjectTargetFrameworks.Net45, DateTime.Now.Ticks.ToString()); string packageInstallOutput = string.Empty; //Install package and get output. Assert.IsTrue(nugetHelper.nuGetPackageManager.InstallPackage(packagePath, out packageInstallOutput)); TestContext.WriteLine("Output from package installation :{0} {1}", Environment.NewLine, packageInstallOutput); //Get output from individual verifiers. bool individualVerifierResults = true; foreach (var verifier in nugetHelper.PackageInstallationVerifiers) { bool?passed = verifier.Value.Validate(packagePath, nugetHelper.vsProjectManager); if (!passed.HasValue) { continue; } else { TestContext.WriteLine("Output from {0} :", verifier.Metadata.Name); if (passed == true) { TestContext.WriteLine(verifier.Value.Output); } if (passed == false) { individualVerifierResults = false; TestContext.WriteLine(verifier.Value.Error); } } } Assert.IsTrue(individualVerifierResults, "Verification from individual verifiers has failed. Check logs for details"); nugetHelper.vsProjectManager.CloseSolution(); } }