Initialize CBDD solution and add a .NET-focused gitignore for generated artifacts.
This commit is contained in:
44
tests/CBDD.Tests/ValueObjectIdTests.cs
Executable file
44
tests/CBDD.Tests/ValueObjectIdTests.cs
Executable file
@@ -0,0 +1,44 @@
|
||||
using ZB.MOM.WW.CBDD.Bson;
|
||||
using ZB.MOM.WW.CBDD.Core;
|
||||
using ZB.MOM.WW.CBDD.Core.Collections;
|
||||
using ZB.MOM.WW.CBDD.Core.Metadata;
|
||||
using ZB.MOM.WW.CBDD.Shared;
|
||||
using Xunit;
|
||||
|
||||
namespace ZB.MOM.WW.CBDD.Tests;
|
||||
|
||||
public class ValueObjectIdTests : IDisposable
|
||||
{
|
||||
private readonly string _dbPath = "value_object_ids.db";
|
||||
private readonly Shared.TestDbContext _db;
|
||||
|
||||
public ValueObjectIdTests()
|
||||
{
|
||||
if (File.Exists(_dbPath)) File.Delete(_dbPath);
|
||||
_db = new Shared.TestDbContext(_dbPath);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Should_Support_ValueObject_Id_Conversion()
|
||||
{
|
||||
var order = new Order
|
||||
{
|
||||
Id = new OrderId("ORD-123"),
|
||||
CustomerName = "John Doe"
|
||||
};
|
||||
|
||||
_db.Orders.Insert(order);
|
||||
|
||||
var retrieved = _db.Orders.FindById(new OrderId("ORD-123"));
|
||||
|
||||
retrieved.ShouldNotBeNull();
|
||||
retrieved.Id.Value.ShouldBe("ORD-123");
|
||||
retrieved.CustomerName.ShouldBe("John Doe");
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_db.Dispose();
|
||||
if (File.Exists(_dbPath)) File.Delete(_dbPath);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user