我已經看了很多例子,但在這種情況下,我希望得到一個新的眼睛重構下面的這個方法,以便我可以單元測試它。我使用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種解決方案進行響應。 –