2011-06-02 84 views
1

我正在根據其相關對象中的屬性加載單個業務對象。在這種情況下,有一種擴展材料與材料和工廠具有單一的關係。通過相關業務對象上的屬性加載單個業務對象

此方法位於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); 
    } 
+0

Hi @GloryDe​​v。你使用的是什麼版本的Habanero? – 2011-06-03 08:24:53

+0

來自sourceforge的最新主幹 – GloryDev 2011-06-03 10:15:07

回答

3

這並不工作,如果你的DataAccessor是DataAccessorDB,但我在一些單元測試,它不反對DataAccessorInMemory工作,最近發現。嘗試使用數據庫的測試,看看是否有效。如果它不請,請登錄http://redmine.habanerowiki.com/

+0

感謝彼得我在Redmine中登錄爲http://redmine.habanerowiki.com/issues/1751 – GloryDev 2011-06-03 10:32:24

+0

此問題現已得到解決,將在下一版Habanero中解決 – 2011-09-16 13:11:04