[link sdk] Adjust the LinkSdkRegressionTest.SpecialFolder to handle uncertainty whether a directory exists or not on .NET. Fixes #xamarin/maccore@2379. (#10511)
The directory does not exist for me locally, but exists when running the tests on the bots. Fixes https://github.com/xamarin/maccore/issues/2379.
This commit is contained in:
Родитель
2a61296464
Коммит
df4388e8d1
|
@ -822,15 +822,17 @@ namespace LinkSdk {
|
|||
#endif
|
||||
}
|
||||
|
||||
string TestFolder (Environment.SpecialFolder folder, bool supported = true, bool exists = true, bool readOnly = false)
|
||||
string TestFolder (Environment.SpecialFolder folder, bool supported = true, bool? exists = true, bool readOnly = false)
|
||||
{
|
||||
var path = Environment.GetFolderPath (folder);
|
||||
Assert.That (path.Length > 0, Is.EqualTo (supported), folder.ToString ());
|
||||
if (!supported)
|
||||
return path;
|
||||
|
||||
Assert.That (Directory.Exists (path), Is.EqualTo (exists), path);
|
||||
if (!exists)
|
||||
var dirExists = Directory.Exists (path);
|
||||
if (exists.HasValue)
|
||||
Assert.That (dirExists, Is.EqualTo (exists), path);
|
||||
if (!dirExists)
|
||||
return path;
|
||||
|
||||
string file = Path.Combine (path, "temp.txt");
|
||||
|
@ -954,7 +956,7 @@ namespace LinkSdk {
|
|||
Assert.That (path, Is.EqualTo (docs), "path - MyDocuments");
|
||||
|
||||
#if NET
|
||||
path = TestFolder (Environment.SpecialFolder.ApplicationData, exists: false);
|
||||
path = TestFolder (Environment.SpecialFolder.ApplicationData, exists: null /* may or may not exist */);
|
||||
#else
|
||||
path = TestFolder (Environment.SpecialFolder.ApplicationData);
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче