我为使用资源的类创建测试时遇到了很多问题。
班级概要:
class CardInfo
private readonly Dictionary<int, Card> Cards= new Dictionary<int, Card>
{
[(int)Card.Fireball] = new Card(CardCode.Fireball, ResourceService.MESSAGE_CARD_TITLE_FIREBALL, ResourceService.MESSAGE_CARD_DESCRIPTION_FIREBALL),
};
方法i尝试测试:
public Card getCard(int CardCode) => Cards.ContainsKey(CardCode) ? Cards[CardCode] : new Card(CardCode.NOTSPECIFED, ResourceService.MESSAGE_INTERNAL_ERROR_TITLE_CARDNOTEXISTENT, ResourceService.MESSAGE_INTERNAL_ERROR_BODY_CARDNOTEXISTENT);
在我试过的测试项目中:
[TestMethod]
public async Task getInternalServerResponseErrorUnknownTest()
{
await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
() =>
{
cardService = new CardInfo();
});
此处抛出错误,&#34;未找到ResourceMap&#34;
资源服务中的:
public static string MESSAGE_CARD_TITLE_FIREBALL
{
get
{
return resourceLoader.GetString("MESSAGE_CARD_TITLE_FIREBALL");
}
}
我怎么能解决这个问题?
答案 0 :(得分:0)
Windows 10 UaP仅允许测试项目为UniwersalTestProject,我必须创建ClassLibrary项目并在那里移动资源以使其正常工作。