Almost all of the code to prime the NuGet cache from the archive.

- Created a Configurer class that is responsible for deciding when to run the dotnet first time use
experience and invoke the NuGetCachePrimer.
- Added the NuGetCachePrimer which extract the archive and primes the cache.
-- This is just missing creating the sentinel once restore succeeds.
- Added a shell for the NugetPackagesArchiver, which will be responsible for expanding the archive (likely
replaced in the future by an abstraction from Eric's code or its implementation will simply call Eric's code).
- Added a TemporaryFolder abstration to Internal Abstractions that handles deleting the temporary folder once
we are done with it.
This commit is contained in:
Livar Cunha 2016-06-03 17:36:40 -07:00
commit 84f63029fe
25 changed files with 698 additions and 6 deletions

View file

@ -1,10 +1,12 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Microsoft.DotNet.Tools.Test.Utilities.Mock;
using Microsoft.Extensions.EnvironmentAbstractions;
namespace Microsoft.Extensions.DependencyModel.Tests
@ -13,6 +15,8 @@ namespace Microsoft.Extensions.DependencyModel.Tests
{
private Dictionary<string, string> _files = new Dictionary<string, string>();
public string TemporaryFolder { get; set; }
internal static IFileSystem Empty { get; } = Create().Build();
public static FileSystemMockBuilder Create()
@ -37,15 +41,15 @@ namespace Microsoft.Extensions.DependencyModel.Tests
internal IFileSystem Build()
{
return new FileSystemMock(_files);
return new FileSystemMock(_files, TemporaryFolder);
}
private class FileSystemMock : IFileSystem
{
public FileSystemMock(Dictionary<string, string> files)
public FileSystemMock(Dictionary<string, string> files, string temporaryFolder)
{
File = new FileMock(files);
Directory = new DirectoryMock(files);
Directory = new DirectoryMock(files, temporaryFolder);
}
public IFile File { get; }
@ -85,9 +89,17 @@ namespace Microsoft.Extensions.DependencyModel.Tests
private class DirectoryMock : IDirectory
{
private Dictionary<string, string> _files;
public DirectoryMock(Dictionary<string, string> files)
private readonly TemporaryDirectoryMock _temporaryDirectory;
public DirectoryMock(Dictionary<string, string> files, string temporaryDirectory)
{
_files = files;
_temporaryDirectory = new TemporaryDirectoryMock(temporaryDirectory);
}
public ITemporaryDirectory CreateTemporaryDirectory()
{
return _temporaryDirectory;
}
public bool Exists(string path)
@ -95,6 +107,23 @@ namespace Microsoft.Extensions.DependencyModel.Tests
return _files.Keys.Any(k => k.StartsWith(path));
}
}
private class TemporaryDirectoryMock : ITemporaryDirectoryMock
{
public bool DisposedTemporaryDirectory { get; private set; }
public TemporaryDirectoryMock(string temporaryDirectory)
{
DirectoryPath = temporaryDirectory;
}
public string DirectoryPath { get; }
public void Dispose()
{
DisposedTemporaryDirectory = true;
}
}
}
}