Updated unit test for ShellItem and ShellView

pull/180/head
dahall 2020-10-20 17:48:05 -06:00
parent dc1fce2803
commit d9db18bad4
3 changed files with 44 additions and 0 deletions

View File

@ -4,6 +4,7 @@ using System.Diagnostics;
using System.Drawing;
using System.Runtime.InteropServices.ComTypes;
using Vanara.PInvoke;
using Vanara.PInvoke.Tests;
using static Vanara.PInvoke.Ole32;
using static Vanara.PInvoke.Shell32;
@ -220,5 +221,22 @@ namespace Vanara.Windows.Shell.Tests
}, Throws.Nothing);
Assert.That(() => new ShellItem(PIDL.Null), Throws.Exception);
}
[Test]
public void ToUriTest()
{
using var i = new ShellItem(testDoc);
var testDocUri = new Uri(testDoc);
Assert.That(testDocUri, Is.EqualTo(i.ToUri()));
using var f = new ShellFolder(KNOWNFOLDERID.FOLDERID_ControlPanelFolder);
Assert.That(f.ToUri().ToString(), Is.EqualTo("shell:::" + KNOWNFOLDERID.FOLDERID_ControlPanelFolder.Guid().ToString("B")));
using var d = new ShellItem(Environment.ExpandEnvironmentVariables(@"%USERPROFILE%\Documents\debug.log"));
Assert.That(d.ToUri().ToString(), Is.EqualTo("shell:::{f42ee2d3-909f-4907-8871-4c22fc0bf756}/debug.log"));
using var td = new ShellItem(d.ToUri().ToString());
td.FileSystemPath.WriteValues();
}
}
}

View File

@ -0,0 +1,25 @@
using NUnit.Framework;
using System;
using System.Runtime.InteropServices;
using System.Text;
using Vanara.InteropServices;
using Vanara.PInvoke;
using Vanara.PInvoke.Tests;
using static Vanara.PInvoke.Shell32;
namespace Vanara.Windows.Shell.Tests
{
[TestFixture]
public class ShelViewTests
{
[Test]
public void CreateTest()
{
var form = new System.Windows.Forms.Form() { Size = new System.Drawing.Size(200, 200) };
// TODO: Finishing testing once working
//var shvw = new ShellView(new ShellFolder(TestCaseSources.TempDir)) { Dock = System.Windows.Forms.DockStyle.Fill };
//form.Controls.Add(shvw);
form.ShowDialog();
}
}
}

View File

@ -51,6 +51,7 @@
<Compile Include="BindContextTests.cs" />
<Compile Include="ClipboardTests.cs" />
<Compile Include="ResourceTests.cs" />
<Compile Include="ShellViewTests.cs" />
<Compile Include="WallpaperTests.cs" />
<Compile Include="ShellLinkTests.cs" />
<Compile Include="ShellSearchTests.cs" />