I'm trying to test a private list via the CheckList method in PersistenceSpecification. But I'm not quite getting there. Could anyone help please?
Entity:
public class Item: Entity<int>
{
//values in list are used in later (internal) calculations
private readonly IList<PurchaseInfo> _purchaseInfo = new List<PurchaseInfo>();
public virtual string SupplierCode {get; set;}
}
Map:
public class ItemMap: ClassMap<Item>
{
public ItemMap()
{
Table("ITEM");
Id(u => u.Id).Column("ITEMNR").GeneratedBy.Assigned();
Map(u => I.SupplierCode).Column("SUPPLIERNR");
HasMany<PurchaseInfo>(Reveal.Member<Item>("_purchaseInfo"))
.KeyColumns.Add("ITEMNR")
.KeyColumns.Add("SUPPLIERNR").PropertyRef("SupplierCode");
}
}
Test (this is how I'm trying to do it currently)
[Test]
public void CanMapItem()
{
new PersistenceSpecification<Item>(Session)
.CheckProperty(a => a.Id, 1234)
.CheckProperty(a => a.SupplierCode, "S01")
.CheckList<Item, PurchaseInfo>(Reveal.Member<Item>("_purchaseInfo"), new List<PurchaseInfo>
{
new PurchaseInfo()
{
ItemNr = 1234,
SupplierCode = "S01"
},
new PurchaseInfo()
{
ItemNr = 1234,
SupplierCode = "S02"
}
})
.VerifyTheMappings();
}
The compiler complains that CheckList expects as first argument
System.Linq.Expressions.Expression<System.Func<Item, System.Collections.Generic.IEnumerable<PurchaseInfo>>
while Reveal.Member returns
System.Linq.Expressions.Expression<System.Func<Item, object>>
Reveal.Member
has 2 overloads, one common and one special. use the special one:
.CheckList<Item, PurchaseInfo>(Reveal.Member<Item, IEnumerable<PurchaseInfo>>("_purchaseInfo"),