我正在编写一个编码的 ui 测试,该测试将作用于每晚创建的文件夹。我希望它工作的方式是测试将选择最新的文件夹。
我该怎么做?断言?
该文件夹是从我使用主应用程序打开的文件夹对话框中选择的。然后将文件夹的名称放入主应用程序的文本框中并扫描补丁。
//Expand 'Computer' -> 'network drive (X:)' -> 'great-granparent' -> 'granparent' -> 'parent' -> 'folder' tree item
uIfolder_TreeItem.Expanded = this.Browse_For_FolderParams.UIfolder_TreeItemExpanded;
使用 nXu 的代码我试过这个:
DirectoryInfo root = new DirectoryInfo(@"X:\great-granparent\granparent\parent");
DirectoryInfo[] folders = root.GetDirectories();
DirectoryInfo newest = folders[0];
foreach (var dir in folders)
{
if (dir.CreationTime.CompareTo(newest.CreationTime) > 0)
newest = dir;
}
//Expand 'Computer' -> 'network drive (X:)' -> 'great-granparent' -> 'granparent' -> 'parent' -> 'folder' tree item
newest = this.Browse_For_FolderParams(newest);
结束代码
DirectoryInfo root = new DirectoryInfo(@"X:\great-granparent\granparent\parent");
DirectoryInfo[] folders = root.GetDirectories();
DirectoryInfo newest = folders[0];
foreach (var dir in folders)
{
if (dir.CreationTime.CompareTo(newest.CreationTime) > 0)
newest = dir;
}
uIfolder_TreeItem.SearchProperties["Name"] = newest.Name;
//Expand 'Computer' -> 'network drive (X:)' -> 'great-granparent' -> 'granparent' -> 'parent' -> 'folder' tree item
uIfolder_TreeItem.Expanded = this.Get_FolderParams.UIfolder_TreeItemExpanded;
谢谢您的帮助 :)