コード例 #1
0
        public static void AssertPackageReferenceDoesNotExist(VisualStudioHost visualStudio, ProjectTestExtension project, string packageName, ILogger logger)
        {
            logger.LogInformation($"Checking for PackageReference {packageName}");

            var matches = GetPackageReferences(project)
                          .Where(e => e.Name.Equals(packageName, StringComparison.OrdinalIgnoreCase))
                          .ToList();

            logger.LogInformation($"Matches: {matches.Count}");

            matches.Any().Should().BeFalse($"A PackageReference for {packageName} was found in {project.FullPath}");
        }
コード例 #2
0
        public static void AssetPackageInPackagesConfig(VisualStudioHost visualStudio, ProjectTestExtension project, string packageName, string packageVersion, ILogger logger)
        {
            logger.LogInformation($"Checking project {packageName}");
            var testService = visualStudio.Get <NuGetApexTestService>();

            // Check using the IVs APIs
            var exists = testService.IsPackageInstalled(project.UniqueName, packageName, packageVersion);

            logger.LogInformation($"Exists: {exists}");

            exists.Should().BeTrue(AppendErrors($"{packageName}/{packageVersion} should be installed in {project.Name}", visualStudio));
        }
コード例 #3
0
        /// <summary>
        /// Get the UI window from the project.
        /// Note that the UI window is initialized asynchronously, so we have to poll until it loads. This method will take max 1 minute.
        /// </summary>
        public NuGetUIProjectTestExtension GetUIWindowfromProject(ProjectTestExtension project)
        {
            var uiproject = NuGetApexUITestService.GetApexTestUIProject(project.Name, TimeSpan.FromSeconds(60), TimeSpan.FromSeconds(1));

            return(new NuGetUIProjectTestExtension(uiproject, Logger));
        }
コード例 #4
0
        public static void AssertPackageReferenceExists(VisualStudioHost visualStudio, ProjectTestExtension project, string packageName, string packageVersion, ILogger logger)
        {
            logger.LogInformation($"Checking for PackageReference {packageName} {packageVersion}");

            var matches = GetPackageReferences(project)
                          .Where(e => e.Name.Equals(packageName, StringComparison.OrdinalIgnoreCase) &&
                                 e.LibraryRange.VersionRange.MinVersion.Equals(NuGetVersion.Parse(packageVersion)))
                          .ToList();

            logger.LogInformation($"Matches: {matches.Count}");

            matches.Any().Should().BeTrue($"A PackageReference with {packageName}/{packageVersion} was not found in {project.FullPath}");
        }
コード例 #5
0
        /// <summary>
        /// Get the UI window from the project.
        /// Note that the UI window is initialized asynchronously, so we have to poll until it loads.
        /// </summary>
        /// <param name="project">project for which we want to load a UI window</param>
        /// <param name="timeout">Max time to wait for the UI window to load</param>
        /// <param name="interval">Interval time for checking whether the control is available</param>
        /// <returns></returns>
        public NuGetUIProjectTestExtension GetUIWindowfromProject(ProjectTestExtension project, TimeSpan timeout, TimeSpan interval)
        {
            var uiproject = NuGetApexUITestService.GetApexTestUIProject(project.Name, timeout, interval);

            return(new NuGetUIProjectTestExtension(uiproject, Logger));
        }
コード例 #6
0
ファイル: CommonUtility.cs プロジェクト: dslzuha/nugetclient
        public static void AssertPackageNotInAssetsFile(VisualStudioHost visualStudio, ProjectTestExtension project, string packageName, string packageVersion, ILogger logger)
        {
            logger.LogInformation($"Checking assets file for {packageName}");
            var testService = visualStudio.Get <NuGetApexTestService>();

            testService.WaitForAutoRestore();

            var assetsFilePath = GetAssetsFilePath(project.FullPath);

            // Project has an assets file, let's look there to assert
            var inAssetsFile = IsPackageInstalledInAssetsFile(assetsFilePath, packageName, packageVersion, false);

            logger.LogInformation($"Exists: {inAssetsFile}");

            inAssetsFile.Should().BeFalse(AppendErrors($"{packageName}/{packageVersion} should not be installed in {project.Name}", visualStudio));
        }
コード例 #7
0
        public NuGetUIProjectTestExtension GetUIWindowfromProject(ProjectTestExtension project)
        {
            var uiproject = NuGetApexUITestService.GetApexTestUIProject(project.Name);

            return(new NuGetUIProjectTestExtension(uiproject));
        }
コード例 #8
0
        private static FileInfo GetPackagesConfigFile(ProjectTestExtension project)
        {
            var projectFile = new FileInfo(project.FullPath);

            return(new FileInfo(Path.Combine(projectFile.DirectoryName, "packages.config")));
        }
コード例 #9
0
        public static void AssertPackageIsNotInstalled(NuGetApexTestService testService, ProjectTestExtension project, string packageName, string packageVersion)
        {
            var assetsFilePath = GetAssetsFilePath(project.FullPath);

            if (File.Exists(assetsFilePath))
            {
                // Project has an assets file, let's look there to assert
                var inAssetsFile = IsPackageInstalledInAssetsFile(assetsFilePath, packageName, packageVersion);
                inAssetsFile.Should().BeFalse($"{packageName}-{packageVersion} should not be installed in {project.Name}");
                return;
            }
            // Project has not assets file, let's use IVS API to assert
            testService.Verify.PackageIsNotInstalled(project.UniqueName, packageName, packageVersion);
        }