Initialize CBDD solution and add a .NET-focused gitignore for generated artifacts.

This commit is contained in:
Joseph Doherty
2026-02-20 12:54:07 -05:00
commit b8ed5ec500
214 changed files with 101452 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
using ZB.MOM.WW.CBDD.Core;
using ZB.MOM.WW.CBDD.Core.Collections;
using ZB.MOM.WW.CBDD.Core.Storage;
using ZB.MOM.WW.CBDD.Core.Transactions;
using ZB.MOM.WW.CBDD.Shared;
using ZB.MOM.WW.CBDD.Shared.TestDbContext_TestDbContext_Mappers;
using Xunit;
namespace ZB.MOM.WW.CBDD.Tests;
public class InsertBulkTests : IDisposable
{
private readonly string _testFile;
private readonly Shared.TestDbContext _db;
public InsertBulkTests()
{
_testFile = Path.GetTempFileName();
_db = new Shared.TestDbContext(_testFile);
}
public void Dispose()
{
_db.Dispose();
}
[Fact]
public void InsertBulk_PersistsData_ImmediatelyVisible()
{
var users = new List<User>();
for (int i = 0; i < 50; i++)
{
users.Add(new User { Id = ZB.MOM.WW.CBDD.Bson.ObjectId.NewObjectId(), Name = $"User {i}", Age = 20 });
}
_db.Users.InsertBulk(users);
_db.SaveChanges();
var insertedUsers = _db.Users.FindAll().ToList();
insertedUsers.Count.ShouldBe(50);
}
[Fact]
public void InsertBulk_SpanningMultiplePages_PersistsCorrectly()
{
// 16KB page. User ~50 bytes. 400 users -> ~20KB -> 2 pages.
var users = new List<User>();
for (int i = 0; i < 400; i++)
{
users.Add(new User { Id = ZB.MOM.WW.CBDD.Bson.ObjectId.NewObjectId(), Name = $"User {i} with some long padding text to ensure we fill space {new string('x', 50)}", Age = 20 });
}
_db.Users.InsertBulk(users);
_db.SaveChanges();
_db.Users.Count().ShouldBe(400);
}
}