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;
///
/// Initializes a new instance of the class.
///
public ValueObjectIdTests()
{
if (File.Exists(_dbPath)) File.Delete(_dbPath);
_db = new Shared.TestDbContext(_dbPath);
}
///
/// Executes Should_Support_ValueObject_Id_Conversion.
///
[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");
}
///
/// Executes Dispose.
///
public void Dispose()
{
_db.Dispose();
if (File.Exists(_dbPath)) File.Delete(_dbPath);
}
}