public async Task RemoveItemFromIndex() { // Arrange using var tempFolder = new TemporaryFolderAllocation(); IOEx.CopyDirectory(Assets.SampleIndexAssetsFolder, tempFolder.FolderPath); var api = new IndexApi($"{tempFolder.FolderPath}/"); var index = await api.GetIndexAsync(); var builder = new IndexBuilder(); builder.Sources.Add(new IndexSourceEntry(TestNuGetFeedUrl)); var gbIndex = index.Sources.First(x => x.Key.StartsWith(Routes.Source.IdentifierGameBanana)); // This will be removed. var nugetIndex = index.Sources.First(x => x.Key.StartsWith(Routes.Source.IdentifierNuGet)); // This will be preserved. // Act index = builder.RemoveNotInBuilder(index); // Assert Assert.Null(index.Sources.FirstOrDefault(x => x.Key.StartsWith(Routes.Source.IdentifierGameBanana)).Value); var oldNuGetFolder = Path.Combine(tempFolder.FolderPath, Path.GetDirectoryName(nugetIndex.Value)); var oldGbFolder = Path.Combine(tempFolder.FolderPath, Path.GetDirectoryName(gbIndex.Value)); Assert.True(Directory.Exists(oldNuGetFolder)); Assert.False(Directory.Exists(oldGbFolder)); }
public async Task UpdateExistingIndex() { const int heroesGameId = 6061; // Arrange using var tempFolder = new TemporaryFolderAllocation(); IOEx.CopyDirectory(Assets.GameBananaIndexAssetsFolder, tempFolder.FolderPath); var api = new IndexApi($"{tempFolder.FolderPath}/"); var index = await api.GetIndexAsync(); var builder = new IndexBuilder(); builder.Sources.Add(new IndexSourceEntry(TestNuGetFeedUrl)); // Act index = await builder.UpdateAsync(index); // Assert Assert.True(index.TryGetNuGetSourcePath(TestNuGetFeedUrl, out _)); Assert.True(index.TryGetGameBananaSourcePath(heroesGameId, out _)); Assert.True(Directory.Exists(index.BaseUrl.LocalPath)); }