mirror of https://github.com/dahall/Vanara.git
Tested #242 and suggested workaround.
parent
b80de57949
commit
346e082d4b
|
@ -3,6 +3,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.InteropServices.ComTypes;
|
||||
|
@ -168,11 +169,13 @@ namespace Vanara.Windows.Shell.Tests
|
|||
[Test]
|
||||
public void GetPropTest()
|
||||
{
|
||||
using var i = new ShellItem(testDoc);
|
||||
using (var i = new ShellItem(testDoc))
|
||||
{
|
||||
Assert.That(i.Properties.Count, Is.GreaterThan(0));
|
||||
Assert.That(i.Properties[PROPERTYKEY.System.Author], Has.Member("TestAuthor"));
|
||||
Assert.That(i.Properties[PROPERTYKEY.System.ItemTypeText], Does.StartWith("Microsoft Word"));
|
||||
Assert.That(i.Properties[PROPERTYKEY.System.DateAccessed], Is.TypeOf<FILETIME>());
|
||||
Assert.That((ulong)i.Properties[PROPERTYKEY.System.FileFRN], Is.GreaterThan((ulong)0));
|
||||
Assert.That(i.Properties[new PROPERTYKEY()], Is.Null);
|
||||
Assert.That(i.Properties[new PROPERTYKEY(Guid.NewGuid(), 2)], Is.Null);
|
||||
|
||||
|
@ -185,6 +188,11 @@ namespace Vanara.Windows.Shell.Tests
|
|||
Assert.That(() => i.Properties.GetProperty<int>(PROPERTYKEY.System.ApplicationName), Throws.Exception);
|
||||
}
|
||||
|
||||
// Test to ensure file handle was released
|
||||
GC.Collect(); // -- This is needed or IPropertyStore may not be released which holds a lock to the file.
|
||||
Assert.That(() => { using var fs = new FileStream(testDoc, FileMode.Open, FileAccess.Read, FileShare.None); fs.Close(); }, Throws.Nothing);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetToolTipTest()
|
||||
{
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Vanara.Windows.Shell
|
|||
public sealed class ShellItemPropertyStore : PropertyStore
|
||||
{
|
||||
/// <summary>The shell item</summary>
|
||||
private readonly ShellItem shellItem;
|
||||
private ShellItem shellItem;
|
||||
|
||||
/// <summary>The flags.</summary>
|
||||
private GETPROPERTYSTOREFLAGS flags = GETPROPERTYSTOREFLAGS.GPS_DEFAULT;
|
||||
|
|
Loading…
Reference in New Issue