public void GivenARootWithNonAsciiCharacterInstallSucceeds() { var nugetConfigPath = GenerateRandomNugetConfigFilePath(); var surrogate = char.ConvertFromUtf32(int.Parse("2A601", NumberStyles.HexNumber)); string nonAscii = "ab Ṱ̺̺̕o 田中さん åä," + surrogate; var root = _testAssetsManager.CreateTestDirectory(testName: nonAscii, identifier: "root"); var reporter = new BufferedReporter(); var fileSystem = new FileSystemWrapper(); var store = new ToolPackageStoreAndQuery(new DirectoryPath(root.Path)); WriteNugetConfigFileToPointToTheFeed(fileSystem, nugetConfigPath); var installer = new ToolPackageInstaller( store: store, projectRestorer: new Stage2ProjectRestorer(Log, reporter), tempProject: GetUniqueTempProjectPathEachTest(), offlineFeed: new DirectoryPath("does not exist")); var package = installer.InstallPackage(new PackageLocation(nugetConfig: nugetConfigPath), packageId: TestPackageId, versionRange: VersionRange.Parse(TestPackageVersion), targetFramework: _testTargetframework); AssertPackageInstall(reporter, fileSystem, package, store, store); new ToolPackageUninstaller(store).Uninstall(package.PackageDirectory); }
) Setup( bool useMock, List <MockFeed> feeds = null, FilePath?tempProject = null, DirectoryPath?offlineFeed = null, FilePath?writeLocalFeedToNugetConfig = null, [CallerMemberName] string callingMethod = "", string identiifer = null) { var root = new DirectoryPath(_testAssetsManager.CreateTestDirectory(callingMethod, identifier: useMock.ToString() + identiifer).Path); var reporter = new BufferedReporter(); IFileSystem fileSystem; IToolPackageStore store; IToolPackageStoreQuery storeQuery; IToolPackageInstaller installer; IToolPackageUninstaller uninstaller; if (useMock) { fileSystem = new FileSystemMockBuilder().Build(); var frameworksMap = new Dictionary <PackageId, IEnumerable <NuGetFramework> >() { { TestPackageId, TestFrameworks } }; WriteNugetConfigFileToPointToTheFeed(fileSystem, writeLocalFeedToNugetConfig); var toolPackageStoreMock = new ToolPackageStoreMock(root, fileSystem, frameworksMap); store = toolPackageStoreMock; storeQuery = toolPackageStoreMock; installer = new ToolPackageInstallerMock( fileSystem: fileSystem, store: toolPackageStoreMock, projectRestorer: new ProjectRestorerMock( fileSystem: fileSystem, reporter: reporter, feeds: feeds == null ? GetMockFeedsForConfigFile(writeLocalFeedToNugetConfig) : feeds.Concat(GetMockFeedsForConfigFile(writeLocalFeedToNugetConfig)).ToList()), frameworksMap: frameworksMap); uninstaller = new ToolPackageUninstallerMock(fileSystem, toolPackageStoreMock); } else { fileSystem = new FileSystemWrapper(); WriteNugetConfigFileToPointToTheFeed(fileSystem, writeLocalFeedToNugetConfig); var toolPackageStore = new ToolPackageStoreAndQuery(root); store = toolPackageStore; storeQuery = toolPackageStore; installer = new ToolPackageInstaller( store: store, projectRestorer: new Stage2ProjectRestorer(Log, reporter), tempProject: tempProject ?? GetUniqueTempProjectPathEachTest(), offlineFeed: offlineFeed ?? new DirectoryPath("does not exist")); uninstaller = new ToolPackageUninstaller(store); } store.Root.Value.Should().Be(Path.GetFullPath(root.Value)); return(store, storeQuery, installer, uninstaller, reporter, fileSystem); }
public void GivenARootWithNonAsciiCharactorInstallSucceeds() { var nugetConfigPath = WriteNugetConfigFileToPointToTheFeed(); var surrogate = char.ConvertFromUtf32(int.Parse("2A601", NumberStyles.HexNumber)); string nonAscii = "ab Ṱ̺̺̕o 田中さん åä," + surrogate; var root = new DirectoryPath(Path.Combine(TempRoot.Root, nonAscii, Path.GetRandomFileName())); var reporter = new BufferedReporter(); var fileSystem = new FileSystemWrapper(); var store = new ToolPackageStore(root); var installer = new ToolPackageInstaller( store: store, projectRestorer: new ProjectRestorer(reporter), tempProject: GetUniqueTempProjectPathEachTest(), offlineFeed: new DirectoryPath("does not exist")); var package = installer.InstallPackage(new PackageLocation(nugetConfig: nugetConfigPath), packageId: TestPackageId, versionRange: VersionRange.Parse(TestPackageVersion), targetFramework: _testTargetframework); AssertPackageInstall(reporter, fileSystem, package, store); package.Uninstall(); }
) Setup( bool useMock, List <MockFeed> feeds = null, FilePath?tempProject = null, DirectoryPath?offlineFeed = null, [CallerMemberName] string testName = "", string identifier = null) { var root = new DirectoryPath(_testAssetsManager.CreateTestDirectory(testName, identifier).Path); var reporter = new BufferedReporter(); IFileSystem fileSystem; IToolPackageStore store; IToolPackageStoreQuery storeQuery; IToolPackageInstaller installer; IToolPackageUninstaller uninstaller; if (useMock) { var packagedShimsMap = new Dictionary <PackageId, IReadOnlyList <FilePath> > { [TestPackageId] = new FilePath[] { new FilePath("path/demo.exe") } }; fileSystem = new FileSystemMockBuilder().Build(); var toolPackageStoreMock = new ToolPackageStoreMock(root, fileSystem); store = toolPackageStoreMock; storeQuery = toolPackageStoreMock; installer = new ToolPackageInstallerMock( fileSystem: fileSystem, store: toolPackageStoreMock, projectRestorer: new ProjectRestorerMock( fileSystem: fileSystem, reporter: reporter, feeds: feeds), packagedShimsMap: packagedShimsMap); uninstaller = new ToolPackageUninstallerMock(fileSystem, toolPackageStoreMock); } else { fileSystem = new FileSystemWrapper(); var toolPackageStore = new ToolPackageStoreAndQuery(root); store = toolPackageStore; storeQuery = toolPackageStore; installer = new ToolPackageInstaller( store: store, projectRestorer: new Stage2ProjectRestorer(Log, reporter), tempProject: tempProject ?? GetUniqueTempProjectPathEachTest(), offlineFeed: offlineFeed ?? new DirectoryPath("does not exist")); uninstaller = new ToolPackageUninstaller(store); } store.Root.Value.Should().Be(Path.GetFullPath(root.Value)); return(store, storeQuery, installer, uninstaller, reporter, fileSystem); }
) Setup( bool useMock, IEnumerable <MockFeed> feeds = null, FilePath?tempProject = null, DirectoryPath?offlineFeed = null) { var root = new DirectoryPath(Path.Combine(TempRoot.Root, Path.GetRandomFileName())); var reporter = new BufferedReporter(); IFileSystem fileSystem; IToolPackageStore store; IToolPackageStoreQuery storeQuery; IToolPackageInstaller installer; IToolPackageUninstaller uninstaller; if (useMock) { var packagedShimsMap = new Dictionary <PackageId, IReadOnlyList <FilePath> > { [TestPackageId] = new FilePath[] { new FilePath("path/demo.exe") } }; fileSystem = new FileSystemMockBuilder().Build(); var toolPackageStoreMock = new ToolPackageStoreMock(root, fileSystem); store = toolPackageStoreMock; storeQuery = toolPackageStoreMock; installer = new ToolPackageInstallerMock( fileSystem: fileSystem, store: toolPackageStoreMock, projectRestorer: new ProjectRestorerMock( fileSystem: fileSystem, reporter: reporter, feeds: feeds), packagedShimsMap: packagedShimsMap); uninstaller = new ToolPackageUninstallerMock(fileSystem, toolPackageStoreMock); } else { fileSystem = new FileSystemWrapper(); var toolPackageStore = new ToolPackageStoreAndQuery(root); store = toolPackageStore; storeQuery = toolPackageStore; installer = new ToolPackageInstaller( store: store, projectRestorer: new ProjectRestorer(reporter), tempProject: tempProject ?? GetUniqueTempProjectPathEachTest(), offlineFeed: offlineFeed ?? new DirectoryPath("does not exist")); uninstaller = new ToolPackageUninstaller(store); } store.Root.Value.Should().Be(Path.GetFullPath(root.Value)); return(store, storeQuery, installer, uninstaller, reporter, fileSystem); }
) Setup( bool useMock, List <MockFeed> feeds = null, FilePath?tempProject = null, DirectoryPath?offlineFeed = null, FilePath?writeLocalFeedToNugetConfig = null) { var root = new DirectoryPath(Path.Combine(TempRoot.Root, Path.GetRandomFileName())); var reporter = new BufferedReporter(); IFileSystem fileSystem; IToolPackageStore store; IToolPackageStoreQuery storeQuery; IToolPackageInstaller installer; IToolPackageUninstaller uninstaller; if (useMock) { fileSystem = new FileSystemMockBuilder().Build(); WriteNugetConfigFileToPointToTheFeed(fileSystem, writeLocalFeedToNugetConfig); var toolPackageStoreMock = new ToolPackageStoreMock(root, fileSystem); store = toolPackageStoreMock; storeQuery = toolPackageStoreMock; installer = new ToolPackageInstallerMock( fileSystem: fileSystem, store: toolPackageStoreMock, projectRestorer: new ProjectRestorerMock( fileSystem: fileSystem, reporter: reporter, feeds: feeds == null ? GetMockFeedsForConfigFile(writeLocalFeedToNugetConfig) : feeds.Concat(GetMockFeedsForConfigFile(writeLocalFeedToNugetConfig)).ToList())); uninstaller = new ToolPackageUninstallerMock(fileSystem, toolPackageStoreMock); } else { fileSystem = new FileSystemWrapper(); WriteNugetConfigFileToPointToTheFeed(fileSystem, writeLocalFeedToNugetConfig); var toolPackageStore = new ToolPackageStoreAndQuery(root); store = toolPackageStore; storeQuery = toolPackageStore; installer = new ToolPackageInstaller( store: store, projectRestorer: new ProjectRestorer(reporter), tempProject: tempProject ?? GetUniqueTempProjectPathEachTest(), offlineFeed: offlineFeed ?? new DirectoryPath("does not exist")); uninstaller = new ToolPackageUninstaller(store); } store.Root.Value.Should().Be(Path.GetFullPath(root.Value)); return(store, storeQuery, installer, uninstaller, reporter, fileSystem); }
private static (IToolPackageStore, IToolPackageInstaller, BufferedReporter, IFileSystem) Setup( bool useMock, IEnumerable <MockFeed> feeds = null, FilePath?tempProject = null, DirectoryPath?offlineFeed = null) { var root = new DirectoryPath(Path.Combine(TempRoot.Root, Path.GetRandomFileName())); var reporter = new BufferedReporter(); IFileSystem fileSystem; IToolPackageStore store; IToolPackageInstaller installer; if (useMock) { fileSystem = new FileSystemMockBuilder().Build(); store = new ToolPackageStoreMock(root, fileSystem); installer = new ToolPackageInstallerMock( fileSystem: fileSystem, store: store, projectRestorer: new ProjectRestorerMock( fileSystem: fileSystem, reporter: reporter, feeds: feeds)); } else { fileSystem = new FileSystemWrapper(); store = new ToolPackageStore(root); installer = new ToolPackageInstaller( store: store, projectRestorer: new ProjectRestorer(reporter), tempProject: tempProject ?? GetUniqueTempProjectPathEachTest(), offlineFeed: offlineFeed ?? new DirectoryPath("does not exist")); } store.Root.Value.Should().Be(Path.GetFullPath(root.Value)); return(store, installer, reporter, fileSystem); }
private (IToolPackageStore, IToolPackageInstaller, BufferedReporter, IFileSystem) Setup( bool useMock, string testDirectory, List <MockFeed> feeds = null, FilePath?tempProject = null, DirectoryPath?offlineFeed = null) { var root = new DirectoryPath(Path.Combine(Directory.GetCurrentDirectory(), Path.GetRandomFileName())); var reporter = new BufferedReporter(); IFileSystem fileSystem; IToolPackageStore store; IToolPackageInstaller installer; if (useMock) { fileSystem = new FileSystemMockBuilder().Build(); store = new ToolPackageStoreMock(root, fileSystem); installer = new ToolPackageInstallerMock( fileSystem: fileSystem, store: store, projectRestorer: new ProjectRestorerMock( fileSystem: fileSystem, reporter: reporter, feeds: feeds)); } else { fileSystem = new FileSystemWrapper(); store = new ToolPackageStoreAndQuery(root); installer = new ToolPackageInstaller( store: store, projectRestorer: new Stage2ProjectRestorer(Log, reporter), tempProject: tempProject ?? GetUniqueTempProjectPathEachTest(testDirectory), offlineFeed: offlineFeed ?? new DirectoryPath("does not exist")); } return(store, installer, reporter, fileSystem); }