Exemplo n.º 1
0
        private async Task FetchOnlineData()
        {
            // We ensure that the self-updater task starts once the app is running because it might invoke dialogs.
            IsSynchronizing = true;
            await Task.Run(async() =>
            {
                await RetrieveLocalXenkoVersions();
                await RunLockTask(() => SelfUpdater.SelfUpdate(ServiceProvider, store));
                await RetrieveServerXenkoVersions();
                await VsixPackage.UpdateFromStore();
                await CheckForFirstInstall();
                await FetchNewsPages();
            });

            IsSynchronizing = false;
        }
Exemplo n.º 2
0
        public void SelfUpdateNoCommandLinePackageOnServerThrows()
        {
            // Arrange
            var factory = new Mock <IPackageRepositoryFactory>();

            factory.Setup(m => m.CreateRepository(It.IsAny <string>())).Returns(new MockPackageRepository());

            ConsoleInfo consoleInfo = GetConsoleInfo();
            var         selfUpdater = new SelfUpdater(factory.Object)
            {
                Console = consoleInfo.Console
            };

            // Act
            ExceptionAssert.Throws <CommandLineException>(() => selfUpdater.SelfUpdate("c:\foo.exe", new SemanticVersion("2.0")),
                                                          "Unable to find 'NuGet.CommandLine' package.");
        }
Exemplo n.º 3
0
        public void SelfUpdateNoNuGetExeInNuGetExePackageThrows()
        {
            // Arrange
            var factory    = new Mock <IPackageRepositoryFactory>();
            var repository = new MockPackageRepository();

            repository.Add(PackageUtility.CreatePackage("NuGet.CommandLine", "3.0"));
            factory.Setup(m => m.CreateRepository(It.IsAny <string>())).Returns(repository);

            ConsoleInfo consoleInfo = GetConsoleInfo();
            var         selfUpdater = new SelfUpdater(factory.Object)
            {
                Console = consoleInfo.Console
            };

            // Act & Assert
            ExceptionAssert.Throws <CommandLineException>(() => selfUpdater.SelfUpdate("c:\foo.exe", new SemanticVersion("2.0")),
                                                          "Invalid NuGet.CommandLine package. Unable to locate NuGet.exe within the package.");
        }
Exemplo n.º 4
0
        public void SelfUpdateOlderVersionDoesNotUpdate()
        {
            // Arrange
            var factory    = new Mock <IPackageRepositoryFactory>();
            var repository = new MockPackageRepository();

            repository.Add(PackageUtility.CreatePackage("NuGet.CommandLine", "1.0"));
            factory.Setup(m => m.CreateRepository(It.IsAny <string>())).Returns(repository);

            ConsoleInfo consoleInfo = GetConsoleInfo();
            var         selfUpdater = new SelfUpdater(factory.Object)
            {
                Console = consoleInfo.Console
            };

            // Act
            selfUpdater.SelfUpdate("c:\foo.exe", new SemanticVersion("2.0"));

            // Assert
            Assert.Equal("NuGet.exe is up to date.", consoleInfo.WrittenLines[0]);
        }