Exemplo n.º 1
0
        public GivenANuGetCachePrimer()
        {
            var fileSystemMockBuilder = FileSystemMockBuilder.Create();

            fileSystemMockBuilder.TemporaryFolder = TEMPORARY_FOLDER_PATH;
            fileSystemMockBuilder.AddFile(COMPRESSED_ARCHIVE_PATH);
            _fileSystemMock         = fileSystemMockBuilder.Build();
            _temporaryDirectoryMock = (ITemporaryDirectoryMock)_fileSystemMock.Directory.CreateTemporaryDirectory();

            _commandFactoryMock = SetupCommandFactoryMock();

            _nugetPackagesArchiverMock = new Mock <INuGetPackagesArchiver>();
            _nugetPackagesArchiverMock.Setup(n => n.ExtractArchive()).Returns(PACKAGES_ARCHIVE_PATH);
            _nugetPackagesArchiverMock.Setup(n => n.NuGetPackagesArchive).Returns(COMPRESSED_ARCHIVE_PATH);

            _nugetCacheSentinel = new Mock <INuGetCacheSentinel>();

            var nugetCachePrimer = new NuGetCachePrimer(
                _commandFactoryMock.Object,
                _nugetPackagesArchiverMock.Object,
                _nugetCacheSentinel.Object,
                _fileSystemMock.Directory,
                _fileSystemMock.File);

            nugetCachePrimer.PrimeCache();
        }
Exemplo n.º 2
0
        public void It_does_not_prime_the_NuGet_cache_if_the_archive_is_not_found_so_that_we_do_not_need_to_generate_the_archive_for_stage1()
        {
            var fileSystemMockBuilder = FileSystemMockBuilder.Create();
            var fileSystemMock        = fileSystemMockBuilder.Build();

            var commandFactoryMock = SetupCommandFactoryMock();

            var nugetPackagesArchiverMock = new Mock <INuGetPackagesArchiver>();

            nugetPackagesArchiverMock.Setup(n => n.NuGetPackagesArchive).Returns(COMPRESSED_ARCHIVE_PATH);

            var nugetCachePrimer = new NuGetCachePrimer(
                commandFactoryMock.Object,
                nugetPackagesArchiverMock.Object,
                _nugetCacheSentinel.Object,
                fileSystemMock.Directory,
                fileSystemMock.File);

            nugetCachePrimer.PrimeCache();

            nugetPackagesArchiverMock.Verify(n => n.ExtractArchive(), Times.Never);
            commandFactoryMock.Verify(c => c.Create(
                                          It.IsAny <string>(),
                                          It.IsAny <IEnumerable <string> >(),
                                          null,
                                          Constants.DefaultConfiguration), Times.Never);
        }
Exemplo n.º 3
0
        public GivenANuGetCachePrimer()
        {
            var fileSystemMockBuilder = FileSystemMockBuilder.Create();

            fileSystemMockBuilder.TemporaryFolder = TEMPORARY_FOLDER_PATH;
            fileSystemMockBuilder.AddFile(COMPRESSED_ARCHIVE_PATH);
            _fileSystemMock = fileSystemMockBuilder.Build();

            _nugetPackagesArchiverMock = new Mock <INuGetPackagesArchiver>();
            _nugetPackagesArchiverMock.Setup(n => n.NuGetPackagesArchive).Returns(COMPRESSED_ARCHIVE_PATH);

            _nugetCacheSentinel = new Mock <INuGetCacheSentinel>();

            _nugetConfigMock = new Mock <INuGetConfig>();

            _cliFallbackFolderPathCalculator = new CliFallbackFolderPathCalculator();

            var nugetCachePrimer = new NuGetCachePrimer(
                _nugetPackagesArchiverMock.Object,
                _nugetCacheSentinel.Object,
                _nugetConfigMock.Object,
                _cliFallbackFolderPathCalculator,
                _fileSystemMock.File);

            nugetCachePrimer.PrimeCache();
        }
Exemplo n.º 4
0
        public GivenANuGetCachePrimer()
        {
            var fileSystemMockBuilder = FileSystemMockBuilder.Create();
            fileSystemMockBuilder.TemporaryFolder = TEMPORARY_FOLDER_PATH;
            fileSystemMockBuilder.AddFile(COMPRESSED_ARCHIVE_PATH);
            _fileSystemMock = fileSystemMockBuilder.Build();
            _temporaryDirectoryMock = (ITemporaryDirectoryMock)_fileSystemMock.Directory.CreateTemporaryDirectory();

            _commandFactoryMock = SetupCommandFactoryMock();

            _nugetPackagesArchiverMock = new Mock<INuGetPackagesArchiver>();
            _nugetPackagesArchiverMock.Setup(n => n.ExtractArchive()).Returns(PACKAGES_ARCHIVE_PATH);
            _nugetPackagesArchiverMock.Setup(n => n.NuGetPackagesArchive).Returns(COMPRESSED_ARCHIVE_PATH);

            _nugetCacheSentinel = new Mock<INuGetCacheSentinel>();

            var nugetCachePrimer = new NuGetCachePrimer(
                _commandFactoryMock.Object,
                _nugetPackagesArchiverMock.Object,
                _nugetCacheSentinel.Object,
                _fileSystemMock.Directory,
                _fileSystemMock.File);

            nugetCachePrimer.PrimeCache();
        }
Exemplo n.º 5
0
        public void It_does_not_create_a_sentinel_when_restore_fails()
        {
            var nugetCacheSentinel = new Mock <INuGetCacheSentinel>();

            _dotnetRestoreCommandMock.Setup(c => c.Execute()).Returns(new CommandResult(null, -1, null, null));

            var nugetCachePrimer = new NuGetCachePrimer(
                _commandFactoryMock.Object,
                _nugetPackagesArchiverMock.Object,
                nugetCacheSentinel.Object,
                _fileSystemMock.Directory,
                _fileSystemMock.File);

            nugetCachePrimer.PrimeCache();

            nugetCacheSentinel.Verify(n => n.CreateIfNotExists(), Times.Never);
        }
Exemplo n.º 6
0
        public void It_does_not_create_a_sentinel_when_extracting_the_archive_fails()
        {
            var nugetCacheSentinel       = new Mock <INuGetCacheSentinel>();
            var nugetPackagesArchiveMock = new Mock <INuGetPackagesArchiver>();

            nugetPackagesArchiveMock.Setup(n => n.ExtractArchive(It.IsAny <string>())).Throws <Exception>();

            var nugetCachePrimer = new NuGetCachePrimer(
                nugetPackagesArchiveMock.Object,
                nugetCacheSentinel.Object,
                _fileSystemMock.File);

            Action action = () => nugetCachePrimer.PrimeCache();

            action.ShouldThrow <Exception>();
            nugetCacheSentinel.Verify(n => n.CreateIfNotExists(), Times.Never);
        }
Exemplo n.º 7
0
        public void It_does_not_prime_the_NuGet_cache_if_the_archive_is_not_found_so_that_we_do_not_need_to_generate_the_archive_for_stage1()
        {
            var fileSystemMockBuilder = FileSystemMockBuilder.Create();
            var fileSystemMock        = fileSystemMockBuilder.Build();

            var nugetPackagesArchiverMock = new Mock <INuGetPackagesArchiver>();

            nugetPackagesArchiverMock.Setup(n => n.NuGetPackagesArchive).Returns(COMPRESSED_ARCHIVE_PATH);

            var nugetCachePrimer = new NuGetCachePrimer(
                nugetPackagesArchiverMock.Object,
                _nugetCacheSentinel.Object,
                fileSystemMock.File);

            nugetCachePrimer.PrimeCache();

            nugetPackagesArchiverMock.Verify(n => n.ExtractArchive(It.IsAny <string>()), Times.Never);
        }
Exemplo n.º 8
0
        public void It_does_not_run_restore_if_dotnet_new_fails()
        {
            var commandFactoryMock = SetupCommandFactoryMock();

            _dotnetNewCommandMock.Setup(c => c.Execute()).Returns(new CommandResult(null, -1, null, null));

            var nugetCachePrimer = new NuGetCachePrimer(
                commandFactoryMock.Object,
                _nugetPackagesArchiverMock.Object,
                _nugetCacheSentinel.Object,
                _fileSystemMock.Directory,
                _fileSystemMock.File);

            nugetCachePrimer.PrimeCache();

            commandFactoryMock.Verify(
                c => c.Create(
                    "restore",
                    It.IsAny <IEnumerable <string> >(),
                    It.IsAny <NuGetFramework>(),
                    It.IsAny <string>()),
                Times.Never);
        }
Exemplo n.º 9
0
        public void It_does_not_prime_the_NuGet_cache_if_the_archive_is_not_found_so_that_we_do_not_need_to_generate_the_archive_for_stage1()
        {
            var fileSystemMockBuilder = FileSystemMockBuilder.Create();
            var fileSystemMock = fileSystemMockBuilder.Build();

            var commandFactoryMock = SetupCommandFactoryMock();

            var nugetPackagesArchiverMock = new Mock<INuGetPackagesArchiver>();            
            nugetPackagesArchiverMock.Setup(n => n.NuGetPackagesArchive).Returns(COMPRESSED_ARCHIVE_PATH);

            var nugetCachePrimer = new NuGetCachePrimer(
                commandFactoryMock.Object,
                nugetPackagesArchiverMock.Object,
                _nugetCacheSentinel.Object,
                fileSystemMock.Directory,
                fileSystemMock.File);

            nugetCachePrimer.PrimeCache();

            nugetPackagesArchiverMock.Verify(n => n.ExtractArchive(), Times.Never);
            commandFactoryMock.Verify(c => c.Create(
                It.IsAny<string>(),
                It.IsAny<IEnumerable<string>>(),
                null,
                Constants.DefaultConfiguration), Times.Never);
        }
Exemplo n.º 10
0
        public void It_does_not_create_a_sentinel_when_restore_fails()
        {
            var nugetCacheSentinel = new Mock<INuGetCacheSentinel>();
            _dotnetRestoreCommandMock.Setup(c => c.Execute()).Returns(new CommandResult(null, -1, null, null));

            var nugetCachePrimer = new NuGetCachePrimer(
                _commandFactoryMock.Object,
                _nugetPackagesArchiverMock.Object,
                nugetCacheSentinel.Object,
                _fileSystemMock.Directory,
                _fileSystemMock.File);

            nugetCachePrimer.PrimeCache();

            nugetCacheSentinel.Verify(n => n.CreateIfNotExists(), Times.Never);
        }
Exemplo n.º 11
0
        public void It_does_not_run_restore_if_dotnet_new_fails()
        {
            var commandFactoryMock = SetupCommandFactoryMock();
            _dotnetNewCommandMock.Setup(c => c.Execute()).Returns(new CommandResult(null, -1, null, null));

            var nugetCachePrimer = new NuGetCachePrimer(
                commandFactoryMock.Object,
                _nugetPackagesArchiverMock.Object,
                _nugetCacheSentinel.Object,
                _fileSystemMock.Directory,
                _fileSystemMock.File);

            nugetCachePrimer.PrimeCache();

            commandFactoryMock.Verify(
                c => c.Create(
                    "restore",
                    It.IsAny<IEnumerable<string>>(),
                    It.IsAny<NuGetFramework>(),
                    It.IsAny<string>()),
                Times.Never);
        }