【发布时间】:2011-11-28 21:20:31
【问题描述】:
我查看了很多示例,但在这种情况下,我希望重新审视以下重构此方法,以便我可以对其进行单元测试。我正在将 mstest 与 moq 一起使用,并且我知道 appsettings 是一个问题,以及 HttpContext 被密封...... 非常感谢任何帮助或想法(建设性的)。
public void DoClaimSearch(SearchClaimInfo clmRequest)
{
var result = claimManager.ClaimSearch(clmRequest);
if (result.RespMsg.TotalRowCount > Convert.ToInt32(ConfigurationManager.AppSettings.Get("TotalRowCount_Max_ClaimSearch")))
{
string ResKey = HttpContext.GetGlobalResourceObject("Global", "info_toomanyrecordsmatch.Text").ToString();
ResKey = ResKey.Replace("{0}", result.RespMsg.TotalRowCount.ToString());
View.AddNotification(WidgetNotificationType.Error,ResKey);
}
else
{
View.SetWidgetResponseData(result.RespMsg.SearchResults);
}
}
【问题讨论】:
标签: unit-testing refactoring moq mstest