2013-07-17 66 views
2

我正在嘗試使用TestableReceivePipeline爲BizTalk管道構建單元測試。我遵循這裏描述的步驟: Using the Unit Testing Feature with Pipelines單元測試依賴於上下文屬性的BizTalk管道

我試圖測試的管道有一個讀取ReceivedFileName上下文屬性的管道組件。

由於消息沒有通過測試中的FILE適配器,因此context屬性不存在,並且測試失敗。

有沒有什麼辦法可以在測試中注入上下文屬性,即在單元測試中設置ReceivedFileName屬性?

回答

0

在自定義管道中寫入以下代碼:

// This will be the name of file. 
string filename = "NameOfFile"; 

// myMsg is the IBaseMessage which will be the output. 
myMsg.Context.Write("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties", filename); 
myMsg.Context.Promote("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties", filename); 

現在你可以按照你平時的步驟「ReceivedFileName」得到促進。