45 lines
1.1 KiB
C#
Executable File
45 lines
1.1 KiB
C#
Executable File
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);
|
|
}
|
|
}
|