我在asp.net核心的控制器中使用IstringLocalizer来读取共享资源。 在我有一个方法:
foreach (var category in urlCategories)
{
if (category == _localizer.GetString("CategoryWebshop")) model.SelectedIndustries.Add(1);
else if (category == _localizer.GetString("CategoryStore")) model.SelectedIndustries.Add(2);
else if (category == _localizer.GetString("CategoryWebsite")) model.SelectedIndustries.Add(3);
else if (category == _localizer.GetString("CategoryService")) model.SelectedIndustries.Add(4);
else if (category == _localizer.GetString("CategoryProduction")) model.SelectedIndustries.Add(5);
else if (category == _localizer.GetString("CategoryTrade")) model.SelectedIndustries.Add(6);
else if (category == _localizer.GetString("CategoryRestaurant")) model.SelectedIndustries.Add(7);
else if (category == _localizer.GetString("CategoryRealEstate")) model.SelectedIndustries.Add(8);
}
在单元测试中,本地化程序的GetString不允许测试获得100%
如何解决问题或跳过/排除测试部分? 感谢