public void IntRepository_Can_Read_Write()
        {
            var repository = FileRepository.CreateIntRepository(_directory);

            var expectedBytes = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF };

            Assert.Empty(repository.ListKeys());

            repository.StoreValue(0, expectedBytes);
            repository.StoreValue(1, expectedBytes);

            Assert.Equal(
                new[] { 0, 1 },
                repository.ListKeys().OrderBy(i => i));

            Assert.True(repository.ValueExists(0));
            Assert.True(repository.ValueExists(1));

            Assert.Equal(expectedBytes, repository.RetrieveValue(0));
            Assert.Equal(expectedBytes, repository.RetrieveValue(1));

            repository.RemoveValue(0);
            repository.RemoveValue(1);

            Assert.Empty(repository.ListKeys());
            Assert.False(repository.ValueExists(0));
            Assert.False(repository.ValueExists(1));
        }
Beispiel #2
0
 private static IRepository <int> CreateIntRepository(
     string repositoryPath)
 {
     return(FileRepository.CreateIntRepository(
                Path.Combine(repositoryPath, "snapshots")));
 }