我正在尝试根据相关对象中的属性加载单个业务对象。在这种情况下,有一个 ExtendedMaterial,它与 Material 和 Plant 有单一的关系。
此方法在 AppServer 类上。当我使用此代码运行附加测试时,我得到了正确的结果和通过了测试,但是如果我取消注释该行
Broker.GetBusinessObject<ExtendedMaterial>("Plant.PlantCode LIKE " + plantCode);
然后我得到异常Habanero.Base.Exceptions.InvalidPropertyNameException : The given property name 'PlantCode' does not exist in the collection of properties for the class 'ExtendedMaterial'
我究竟做错了什么?
public ExtendedMaterial GetExtendedMaterial(string materialCode, string plantCode)
{
// return Broker.GetBusinessObject<ExtendedMaterial>("Plant.PlantCode LIKE " + plantCode);
return Broker.GetBusinessObjectCollection<ExtendedMaterial>("Plant.PlantCode LIKE " + plantCode).FirstOrDefault();
}
[Test]
public void GetExtendedMaterial_WhenExists_ShouldReturnExtendedMaterial()
{
//---------------Set up test pack-------------------
var material = CreateSavedMaterial();
var plant = GetBOTestFactory<Plant>().CreateSavedBusinessObject();
var extendedMaterial = CreateSavedExtendedMaterial(plant, material);
IAppServer appServer = new AppServer(CreateDeviceManagerWithDevice());
//---------------Assert Precondition----------------
Assert.AreSame(plant, extendedMaterial.Plant);
Assert.AreSame(material, extendedMaterial.Material);
//---------------Execute Test ----------------------
var actualExtendedMaterial = appServer.GetExtendedMaterial(material.Code, plant.PlantCode);
//---------------Test Result -----------------------
Assert.AreSame(extendedMaterial, actualExtendedMaterial);
}