我已经看了很多例子,但在这种情况下,我希望得到一个新的眼睛重构下面的这个方法,以便我可以单元测试它。我使用mstest与moq和我知道appsettings是一个问题,随着HttpContext被密封.... 任何帮助或想法(建设性)非常感激。寻找重构Appsettings和HttpContext的单元测试和moq
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);
}
}
感谢您使用3种解决方案进行响应。 –