Пример #1
0
        public async Task <string> PrepareTestAsync(CachingTestContext context, ICachingCommand command)
        {
            // Add the first version of the package to the global packages folder.
            await context.AddToGlobalPackagesFolderAsync(context.PackageIdentityA, context.PackageAVersionAPath);

            // A different version of the same package is available on the source.
            context.CurrentPackageAPath = context.PackageAVersionBPath;
            context.IsPackageAAvailable = true;

            return(command.PrepareArguments(context, context.PackageIdentityA));
        }
        public Task <string> PrepareTestAsync(CachingTestContext context, ICachingCommand command)
        {
            // Populate the output packages path with a leftover .directdownload file.
            Directory.CreateDirectory(context.OutputPackagesPath);
            var path = Path.Combine(context.OutputPackagesPath, $"leftover.nugetdirectdownload");

            File.WriteAllText(path, string.Empty);

            var args = command.PrepareArguments(context, context.PackageIdentityA);

            return(Task.FromResult(args));
        }
Пример #3
0
        public Task <string> PrepareTestAsync(CachingTestContext context, ICachingCommand command)
        {
            // The second version of the package is available on the source.
            context.IsPackageAAvailable = true;
            context.CurrentPackageAPath = context.PackageAVersionBPath;

            // Add the first version of the package to the HTTP.
            context.AddPackageToHttpCache(context.PackageIdentityA, context.PackageAVersionAPath);

            var args = command.PrepareArguments(context, context.PackageIdentityA);

            return(Task.FromResult(args));
        }
Пример #4
0
        public CachingValidations Validate(CachingTestContext context, ICachingCommand command, CommandRunnerResult result)
        {
            var validations = new CachingValidations();

            validations.Add(
                CachingValidationType.CommandSucceeded,
                result.Item1 == 0);

            validations.Add(
                CachingValidationType.PackageInGlobalPackagesFolder,
                context.IsPackageInGlobalPackagesFolder(context.PackageIdentityB));

            return(validations);
        }
        public CachingValidations Validate(CachingTestContext context, ICachingCommand command, CommandRunnerResult result)
        {
            var validations = new CachingValidations();

            validations.Add(
                CachingValidationType.CommandSucceeded,
                result.Item1 == 0);

            validations.Add(
                CachingValidationType.DirectDownloadFilesDoNotExist,
                !Directory.EnumerateFiles(context.OutputPackagesPath, "*.nugetdirectdownload").Any());

            return(validations);
        }
Пример #6
0
        public CachingValidations Validate(CachingTestContext context, ICachingCommand command, CommandRunnerResult result)
        {
            var validations = new CachingValidations();

            validations.Add(
                CachingValidationType.CommandSucceeded,
                result.ExitCode == 0);

            validations.Add(
                CachingValidationType.PackageInHttpCache,
                context.IsPackageInHttpCache(context.PackageIdentityB));

            return(validations);
        }
Пример #7
0
        public CachingValidations Validate(CachingTestContext context, ICachingCommand command, CommandRunnerResult result)
        {
            var validations = new CachingValidations();

            validations.Add(
                CachingValidationType.CommandSucceeded,
                result.Item1 == 0);

            validations.Add(
                CachingValidationType.PackageInstalled,
                command.IsPackageInstalled(context, context.PackageIdentityA));

            var path = command.GetInstalledPackagePath(context, context.PackageIdentityA);

            validations.Add(
                CachingValidationType.PackageFromHttpCacheUsed,
                path != null && context.IsPackageAVersionA(path));

            validations.Add(
                CachingValidationType.PackageFromSourceNotUsed,
                path == null || !context.IsPackageAVersionB(path));

            return(validations);
        }
Пример #8
0
        public static async Task <IEnumerable <CachingValidations> > ExecuteAsync(ICachingTest test, ICachingCommand command, INuGetExe nuGetExe, CachingType caching, ServerType server)
        {
            using (var testFolder = TestDirectory.Create())
                using (var mockServer = new MockServer())
                {
                    var tc = new CachingTestContext(testFolder, mockServer, nuGetExe);

                    // Enable this flag to launch the debugger when the nuget.exe process starts. This also increases
                    // logging verbosity and command timeout.
                    //
                    // tc.Debug = true;

                    tc.NoCache        = caching.HasFlag(CachingType.NoCache);
                    tc.DirectDownload = caching.HasFlag(CachingType.DirectDownload);
                    tc.CurrentSource  = server == ServerType.V2 ? tc.V2Source : tc.V3Source;

                    tc.ClearHttpCache();
                    var validations = new List <CachingValidations>();
                    for (var i = 0; i < test.IterationCount; i++)
                    {
                        var args = await test.PrepareTestAsync(tc, command);

                        var result = tc.Execute(args);
                        validations.Add(test.Validate(tc, command, result));
                    }

                    return(validations);
                }
        }