Ejemplo n.º 1
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.");
        }
Ejemplo n.º 2
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.");
        }
Ejemplo n.º 3
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]);
        }