public void UriRepository_Can_Read_Write() { var repository = FileRepository.CreateUriRepository(_directory); var expectedBytes = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF }; var uri1 = new Uri("sha256://aa"); var uri2 = new Uri("sha256://bb"); Assert.Empty(repository.ListKeys()); repository.StoreValue(uri1, expectedBytes); repository.StoreValue(uri2, expectedBytes); Assert.Equal( new[] { uri1, uri2 }, repository.ListKeys().OrderBy(u => u.AbsoluteUri)); Assert.True(repository.ValueExists(uri1)); Assert.True(repository.ValueExists(uri2)); Assert.Equal(expectedBytes, repository.RetrieveValue(uri1)); Assert.Equal(expectedBytes, repository.RetrieveValue(uri2)); repository.RemoveValue(uri1); repository.RemoveValue(uri2); Assert.Empty(repository.ListKeys()); Assert.False(repository.ValueExists(uri1)); Assert.False(repository.ValueExists(uri2)); }
private static IRepository <Uri> CreateUriRepository( string repositoryPath) { return(FileRepository.CreateUriRepository( Path.Combine(repositoryPath, "blobs"))); }