1

我正在尝试根据相关对象中的属性加载单个业务对象。在这种情况下,有一个 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);
    }
4

1 回答 1

3

如果您的 DataAccessor 是 DataAccessorDB,这确实有效,但我最近在一些单元测试中注意到它不适用于 DataAccessorInMemory。尝试使用 db 进行测试,看看是否有效。如果没有,请在http://redmine.habanerowiki.com/上记录错误

于 2011-06-03T10:22:35.007 回答