public void ReadCount() { TimeRunner.Run(async(time, th) => { var(dir, _) = BuildData(th); var reader = new Data.Reader(th, dir); Assert.Equal(5, await reader.CountAsync().ConfigureAwait(th)); }); }
public void ReadThreeVersions() { TimeRunner.Run(async(time, th) => { var(dir, expected) = BuildData(th); var reader = new Data.Reader(th, dir); var data = await(await reader.ReadAsync().ConfigureAwait(th)).ToArray().ConfigureAwait(th); Assert.Equal(expected, data); }); }
public void ReadEmpty() { TimeRunner.Run(async(time, th) => { var dir = new FakeDirectory(th); var reader = new Data.Reader(th, dir); var data = await(await reader.ReadAsync().ConfigureAwait(th)).ToArray().ConfigureAwait(th); Assert.Empty(data); }); }
public void WriterWithPreviousVersion() { TimeRunner.Run(async(time, th) => { var idBits = ImmutableArray.Create(DataStore.ID_BYTE_1, DataStore.ID_BYTE_2); var dir = new FakeDirectory(th, ("data.seqid.00000001.version.1.elementsize.8.datastore", Bits.Empty.Concat(idBits).Concat(Bits.Empty.AddInt(1).AddFletcher16)) ); var writer = new Data.Writer(th, dir); var reader = new Data.Reader(th, dir); Assert.Equal(new [] { new Data(1, null, null) }, await(await reader.ReadAsync().ConfigureAwait(th)).ToArray().ConfigureAwait(th)); await writer.AppendAsync(new Data(4, 5, 6)).ConfigureAwait(th); Assert.Equal(new [] { new Data(1, null, null), new Data(4, 5, 6) }, await(await reader.ReadAsync().ConfigureAwait(th)).ToArray().ConfigureAwait(th)); }); }
public void WriterReadSingleVersion() { TimeRunner.Run(async(time, th) => { var dir = new FakeDirectory(th); var writer = new Data.Writer(th, dir); var reader = new Data.Reader(th, dir); Assert.Empty(await(await reader.ReadAsync().ConfigureAwait(th)).ToArray().ConfigureAwait(th)); await writer.AppendAsync(new Data(1, 2, 3)).ConfigureAwait(th); Assert.Equal(new [] { new Data(1, 2, 3) }, await(await reader.ReadAsync().ConfigureAwait(th)).ToArray().ConfigureAwait(th)); await writer.AppendAsync(new Data(4, 5, 6)).ConfigureAwait(th); Assert.Equal(new [] { new Data(1, 2, 3), new Data(4, 5, 6) }, await(await reader.ReadAsync().ConfigureAwait(th)).ToArray().ConfigureAwait(th)); Assert.Single(await dir.ListFilesAsync().ConfigureAwait(th)); }); }
public void ReadPartial() { TimeRunner.Run(async(time, th) => { var(dir, expected) = BuildData(th); var reader = new Data.Reader(th, dir); async Task <Data[]> Read(int from, int to) => await(await reader.ReadAsync(from, to).ConfigureAwait(th)).ToArray().ConfigureAwait(th); for (int start = 0; start < 5; start++) { for (int end = start; end < 5; end++) { Assert.Equal(expected.Skip(start).Take(end - start).ToArray(), await Read(start, end).ConfigureAwait(th)); } } }); }
public void AddEntries() { TimeRunner.Run(async(time, th) => { const string filename = "data.seqid.00000001.version.1.elementsize.8.datastore"; var e = Bits.Empty; var idBits = e.Concat(ImmutableArray.Create(DataStore.ID_BYTE_1, DataStore.ID_BYTE_2)); var data = e.Concat(idBits).Concat(e.AddInt(100).AddFletcher16); var dir = new FakeDirectory(th); var reader = new Data.Reader(th, dir); Assert.Empty(await(await reader.ReadAsync().ConfigureAwait(th)).ToArray().ConfigureAwait(th)); await dir.AppendAsync(filename, data); Assert.Equal(1, await reader.CountAsync().ConfigureAwait(th)); Assert.Single(await(await reader.ReadAsync().ConfigureAwait(th)).ToArray().ConfigureAwait(th)); await dir.AppendAsync(filename, data); Assert.Equal(2, await reader.CountAsync().ConfigureAwait(th)); Assert.Equal(2, (await(await reader.ReadAsync().ConfigureAwait(th)).ToArray().ConfigureAwait(th)).Count()); }); }