Describe the bug
The below unit test works in 5.0.17, but fails in 5.0.18.
I probably shouldn't be relying on Rebuild to dispose LiteDb and flush all pending writes to the stream, but our unit test does it this way and it breaks in 5.0.18 so I thought I would share.
Code to Reproduce
public class ReOpen_Tests
{
[Fact]
public void Should_Open()
{
byte[] databaseBytes;
using (var stream = new MemoryStream())
{
var database = new LiteDatabase(stream);
var collection = database.GetCollection<Item>();
collection.Upsert(new Item(Guid.NewGuid()));
var items = collection.Query().ToList();
items.Should().HaveCount(1);
database.Rebuild();
databaseBytes = stream.ToArray();
}
// Opening the database with the existing stream should have the items still.
using (var stream = new MemoryStream(databaseBytes))
{
var database = new LiteDatabase(stream);
var items = database.GetCollection<Item>().Query().ToList();
items.Should().HaveCount(1);
}
}
private class Item
{
public Item(Guid id)
{
Id = id;
}
public Guid Id { get; set; }
}
}
Version 5.0.18
Describe the bug The below unit test works in 5.0.17, but fails in 5.0.18.
I probably shouldn't be relying on Rebuild to dispose LiteDb and flush all pending writes to the stream, but our unit test does it this way and it breaks in 5.0.18 so I thought I would share.
Code to Reproduce
Expected behavior The test above should pass.