我有一個非常簡單的方法,我試圖測試。 _interactionService會彈出一個對話框,要求用戶確認是否刪除了客戶。如果在框上單擊適當的按鈕,則會調用提供的操作。該操作操縱上下文並保存更改。保存完成後,會調用另一個操作。測試關閉
private void Delete(object entity)
{
_interactionService.ShowConfirmationBox("Delete?", "Are you sure you want to delete this customer?",() =>
{
Customer customer = entity as Customer;
Context.Attach(customer);
Context.Delete(customer);
Context.Save(() => DoSomethingElseWhenSaveComplete);
});
}
我不知道如何測試這種方法。我嘲笑了服務和環境,但是如何測試關閉?
不知道答案,我在想它。你不應該測試私人方法。 – 2012-04-19 15:51:58
爲什麼'tdd'標籤?應該有'單元測試'而不是 – GolfWolf 2012-04-19 15:54:02