Reformat / cleanup
This commit is contained in:
@@ -1,29 +1,24 @@
|
||||
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.Bson;
|
||||
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 TestDbContext _db;
|
||||
private readonly string _testFile;
|
||||
private readonly Shared.TestDbContext _db;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="InsertBulkTests"/> class.
|
||||
/// Initializes a new instance of the <see cref="InsertBulkTests" /> class.
|
||||
/// </summary>
|
||||
public InsertBulkTests()
|
||||
{
|
||||
_testFile = Path.GetTempFileName();
|
||||
_db = new Shared.TestDbContext(_testFile);
|
||||
_db = new TestDbContext(_testFile);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes test resources.
|
||||
/// Disposes test resources.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
@@ -31,16 +26,13 @@ public class InsertBulkTests : IDisposable
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies bulk inserts are immediately persisted and visible.
|
||||
/// Verifies bulk inserts are immediately persisted and visible.
|
||||
/// </summary>
|
||||
[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 });
|
||||
}
|
||||
for (var i = 0; i < 50; i++) users.Add(new User { Id = ObjectId.NewObjectId(), Name = $"User {i}", Age = 20 });
|
||||
|
||||
_db.Users.InsertBulk(users);
|
||||
_db.SaveChanges();
|
||||
@@ -51,21 +43,23 @@ public class InsertBulkTests : IDisposable
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies bulk inserts spanning multiple pages persist correctly.
|
||||
/// Verifies bulk inserts spanning multiple pages persist correctly.
|
||||
/// </summary>
|
||||
[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 });
|
||||
}
|
||||
for (var i = 0; i < 400; i++)
|
||||
users.Add(new User
|
||||
{
|
||||
Id = 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user