Updated tests to fit changes to libs

pull/180/head
dahall 2020-10-22 14:34:26 -06:00
parent a88ec3079c
commit de1840d48a
5 changed files with 24 additions and 23 deletions

View File

@ -35,8 +35,7 @@ namespace Vanara.Windows.Shell.Tests
public void EnumObjectParamTest()
{
using var bc = new BindContext();
Assert.That(bc.EnumObjectParam(), Is.Not.Empty);
TestContext.Write(string.Join(", ", bc.EnumObjectParam()));
Assert.That(() => bc.EnumObjectParam(), Throws.Nothing);
}
}
}

View File

@ -17,7 +17,7 @@ namespace Vanara.Windows.Shell.Tests
[Test]
public void ReadProgIDTest()
{
using (var pi = ProgId.Open("Word.Document.12"))
using (var pi = ProgId.Open("Word.Document.12", systemWide: true))
{
Assert.That(pi.ReadOnly, Is.True);
Assert.That(pi.DefaultIcon.ToString(), Is.EqualTo(@"C:\Program Files (x86)\Microsoft Office\Root\VFS\Windows\Installer\{90160000-000F-0000-0000-0000000FF1CE}\wordicon.exe,13"));
@ -28,13 +28,13 @@ namespace Vanara.Windows.Shell.Tests
Assert.That(pi.Verbs["Close"], Is.Null);
//Assert.That(pi.Verbs["New"].DisplayName, Is.EqualTo("&New"));
}
using (var pi = ProgId.Open("Acrobat.Document.DC"))
{
Assert.That(pi.EditFlags, Is.EqualTo(PInvoke.ShlwApi.FILETYPEATTRIBUTEFLAGS.FTA_OpenIsSafe));
Assert.That(pi.CLSID, Is.EqualTo(new Guid("{B801CA65-A1FC-11D0-85AD-444553540000}")));
Assert.That(pi.Verbs["Print"].Command, Has.Length.GreaterThan(0));
}
using (var pi = ProgId.Open("CABFolder"))
//using (var pi = ProgId.Open("Acrobat.Document.DC", systemWide: true))
//{
// Assert.That(pi.EditFlags, Is.EqualTo(PInvoke.ShlwApi.FILETYPEATTRIBUTEFLAGS.FTA_OpenIsSafe));
// Assert.That(pi.CLSID, Is.EqualTo(new Guid("{B801CA65-A1FC-11D0-85AD-444553540000}")));
// Assert.That(pi.Verbs["Print"].Command, Has.Length.GreaterThan(0));
//}
using (var pi = ProgId.Open("CABFolder", systemWide: true))
{
Assert.That(pi.EditFlags, Is.EqualTo(PInvoke.ShlwApi.FILETYPEATTRIBUTEFLAGS.FTA_SafeForElevation));
Assert.That(pi.FriendlyTypeName.ToString(), Is.EqualTo(@"@C:\WINDOWS\system32\cabview.dll,-20"));
@ -42,9 +42,9 @@ namespace Vanara.Windows.Shell.Tests
Assert.That(pi.InfoTip.ToString(), Is.EqualTo(@"@C:\WINDOWS\system32\cabview.dll,-21"));
Assert.That((pi.InfoTip as IndirectString)?.Value, Has.Length.GreaterThan(0));
}
using (var pi = ProgId.Open("cdafile"))
using (var pi = ProgId.Open("cdafile", systemWide: true))
Assert.That(pi.Verbs, Has.Count.EqualTo(0));
using (var pi = ProgId.Open("Msi.Package"))
using (var pi = ProgId.Open("Msi.Package", systemWide: true))
{
Assert.That(pi.Verbs, Has.Count.EqualTo(4));
Assert.That(pi.Verbs.Order, Has.Count.EqualTo(4));

View File

@ -43,7 +43,7 @@ namespace Vanara.Windows.Shell.Tests
}
}
TestContext.WriteLine("");
Assert.That(c, Is.EqualTo(i.Properties.Descriptions.Count));
Assert.That(c, Is.LessThanOrEqualTo(i.Properties.Descriptions.Count));
}
[Test]
@ -91,7 +91,7 @@ namespace Vanara.Windows.Shell.Tests
// Try accessing a Word file's writable properties and assert successs.
using var w = new ShellItem(testDoc);
w.Properties.ReadOnly = false;
Assert.That(w.Properties.TryGetValue(PROPERTYKEY.System.Size, out _), Is.True);
Assert.That(w.Properties.TryGetValue(PROPERTYKEY.System.Author, out _), Is.True);
}
[Test]

View File

@ -77,7 +77,9 @@ namespace Vanara.Windows.Shell.Tests
ps = i.GetHandler<PropSys.IPropertyStore>();
Assert.That(ps, Is.Not.Null.And.InstanceOf<PropSys.IPropertyStore>());
System.Runtime.InteropServices.Marshal.ReleaseComObject(ps);
Assert.That(() => i.GetHandler<IExtractIcon>(), Throws.TypeOf<ArgumentOutOfRangeException>());
var ei = i.GetHandler<IExtractIcon>();
Assert.That(ei, Is.Not.Null.And.InstanceOf<IExtractIcon>());
//Assert.That(() => i.GetHandler<IExtractIcon>(), Throws.TypeOf<ArgumentOutOfRangeException>());
}
[Test]
@ -87,7 +89,7 @@ namespace Vanara.Windows.Shell.Tests
if (!shellItem.IsFolder)
TestContext.WriteLine(shellItem.Properties[PROPERTYKEY.System.MIMEType]);
using var stream = shellItem.GetStream();
using var stream = shellItem.GetStream(STGM.STGM_READ | STGM.STGM_SIMPLE);
TestContext.WriteLine(((FormattableString)$"{shellItem.FileSystemPath} ({stream.Length:B3})").ToString(ByteSizeFormatter.Instance));
}
@ -146,13 +148,12 @@ namespace Vanara.Windows.Shell.Tests
Assert.That(() =>
{
using var i = new ShellItem(testDoc);
Assert.That(() => i.GetPropertyDescriptionList(PROPERTYKEY.System.Category), Throws.Exception);
using var pdl = i.GetPropertyDescriptionList(PROPERTYKEY.System.PropList.FullDetails);
using var pdl = i.GetPropertyDescriptionList();
Assert.That(pdl.Count, Is.GreaterThan(0));
foreach (var d in pdl)
{
Assert.That(d.TypeFlags, Is.Not.Zero);
Debug.WriteLine($"Property '{d.DisplayName}' is of type '{d.PropertyType}'");
Debug.WriteLine($"Property '{d.DisplayName}' is of type '{d.PropertyType?.Name}'");
}
}, Throws.Nothing);
}
@ -173,8 +174,8 @@ namespace Vanara.Windows.Shell.Tests
Assert.That(() => i.Properties[null], Throws.Exception);
Assert.That(() => i.Properties["Arthur"], Throws.Exception);
Assert.That(i.Properties.GetProperty<string>(PROPERTYKEY.System.Company), Is.InstanceOf<string>().And.StartWith("Microsoft"));
Assert.That(() => i.Properties.GetProperty<int>(PROPERTYKEY.System.Company), Throws.Exception);
Assert.That(i.Properties.GetProperty<string>(PROPERTYKEY.System.ApplicationName), Is.InstanceOf<string>().And.StartWith("Microsoft"));
Assert.That(() => i.Properties.GetProperty<int>(PROPERTYKEY.System.ApplicationName), Throws.Exception);
}
[Test]
@ -207,8 +208,8 @@ namespace Vanara.Windows.Shell.Tests
Assert.That(i.FileSystemPath, Is.EqualTo(testDoc));
i.Update();
}, Throws.Nothing);
Assert.That(() => new ShellItem((string)null), Throws.Exception);
Assert.That(() => new ShellItem(badTestDoc), Throws.Nothing);
Assert.That(() => new ShellItem((string)null), Throws.ArgumentNullException);
Assert.That(() => new ShellItem(badTestDoc), Throws.InstanceOf<System.IO.FileNotFoundException>());
}
[Test]

View File

@ -17,6 +17,7 @@ namespace Vanara.Windows.Shell.Tests
public void UnsavedLinkTest()
{
using var lnk = new ShellLink(TestCaseSources.WordDoc, "/p", TestCaseSources.TempDir, "Test description");
lnk.Properties.ReadOnly = false;
lnk.Title = "Test title";
lnk.HotKey = Keys.Control | Keys.T;
lnk.RunAsAdministrator = false;