Exemple #1
0
        public async Task SelfUpdater_WithV3Server_SucceedsAsync()
        {
            using (var testDirectory = TestDirectory.Create())
            {
                var tc = new TestContext(testDirectory);
                using (var mockServer = new FileSystemBackedV3MockServer(tc.SourceDirectory))
                {
                    await SimpleTestPackageUtility.CreatePackagesAsync(tc.SourceDirectory,
                                                                       GetNuGetCommandLinePackage(tc, "6.0.0", isExpected : false),
                                                                       GetNuGetCommandLinePackage(tc, "6.5.0", isExpected : true)
                                                                       );

                    mockServer.Start();

                    // Act
                    await tc.Target.UpdateSelfFromVersionAsync(
                        tc.Target.AssemblyLocation,
                        prerelease : false,
                        currentVersion : new NuGetVersion("5.5.0"),
                        mockServer.ServiceIndexUri,
                        CancellationToken.None);

                    // Assert
                    tc.VerifyReplacedState(replaced: true);
                }
            }
        }
Exemple #2
0
        public async Task SelfUpdater_WithV3Server_WithUnlistedPackages_IgnoresUnlistedPackagesAsync()
        {
            using (var testDirectory = TestDirectory.Create())
            {
                var tc = new TestContext(testDirectory);
                using (var mockServer = new FileSystemBackedV3MockServer(tc.SourceDirectory))
                {
                    var expectedPackage = GetNuGetCommandLinePackage(tc, "6.0.0", isExpected: true);
                    // This package is unlisted, so we expect 6.0.0 to be chosen.
                    var unlistedPackage = GetNuGetCommandLinePackage(tc, "6.5.0", isExpected: false);

                    await SimpleTestPackageUtility.CreatePackagesAsync(tc.SourceDirectory,
                                                                       expectedPackage,
                                                                       unlistedPackage
                                                                       );

                    mockServer.UnlistedPackages.Add(unlistedPackage.Identity);
                    mockServer.Start();

                    // Act
                    await tc.Target.UpdateSelfFromVersionAsync(
                        tc.Target.AssemblyLocation,
                        prerelease : false,
                        currentVersion : new NuGetVersion("5.5.0"),
                        mockServer.ServiceIndexUri,
                        CancellationToken.None);

                    // Assert
                    tc.VerifyReplacedState(replaced: true);
                }
            }
        }