希望测试验证所有导航路径都符合预期,因此如果有人更改导航路径,测试将会捕获它。
[TestMethod]
public void NavigationServiceIsConfigured()
{
NavigationService service = new NavigationService();
// this is code under test put here for reference
service.Configure("MainPage", typeof(MainPage));
service.NavigateTo("MainPage");
// Verify
Assert.AreEqual("MainPage", service.CurrentPageKey);
}
然而,它并没有真正测试我想要测试的内容。
是否有办法访问存储字符串和类型的字典?
答案 0 :(得分:0)
以这种方式解决这个问题:
public class DefaultNavigationService : NavigationService
{
public Dictionary<string, Type> Configuration
{
get;
private set;
}
public DefaultNavigationService() : base()
{
Configuration = new Dictionary<string, Type>();
}
public new void Configure(string key, Type pageType)
{
Configuration.Add(key, pageType);
base.Configure(key, pageType);
}
}