|
using System;
using System.IO;
using System.Reflection;
using System.Resources;
using Pvax.Shell;
using NUnit.Framework;
namespace Pvax.Shell.Tests
{
[TestFixture]
public class TestShellLink
{
private string testFolderPath;
[TestFixtureSetUp]
public void FixtureInit()
{
testFolderPath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Pvax.Shell.Tests");
Directory.CreateDirectory(testFolderPath);
}
[TestFixtureTearDown]
public void FixtureDone()
{
string[] files = Directory.GetFiles(testFolderPath, "*.*");
foreach(string file in files)
File.Delete(file);
Directory.Delete(testFolderPath);
}
[Test]
public void TestArguments()
{
ShellLink link = new ShellLink();
link.Arguments = null;
Assert.AreEqual("", link.Arguments);
link.Arguments = "/b";
Assert.AreEqual("/b", link.Arguments);
}
[Test]
public void TestDescription()
{
ShellLink link = new ShellLink();
link.Description = null;
Assert.AreEqual("", link.Description);
link.Description = "Some textual description";
Assert.AreEqual("Some textual description", link.Description);
}
private const short hotkey = 0x09 | (0x04 << 8); // VK_TAB | (HOTKEYF_ALT << 8);
[Test]
public void TestHotkey()
{
ShellLink link = new ShellLink();
link.Hotkey = hotkey;
Assert.AreEqual(hotkey, link.Hotkey);
}
[Test]
public void TestIconPath()
{
ShellLink link = new ShellLink();
link.IconPath = null;
Assert.AreEqual("", link.IconPath);
link.IconPath = @"C:\Windows\System32\shell32.dll";
Assert.AreEqual(@"C:\Windows\System32\shell32.dll", link.IconPath);
}
[Test]
public void TestIconIndex()
{
ShellLink link = new ShellLink();
link.IconIndex = 3;
Assert.AreEqual(3, link.IconIndex);
}
[Test]
public void TestPath()
{
ShellLink link = new ShellLink();
link.Path = null;
Assert.AreEqual("", link.Path);
link.Path = @"C:\Windows\System32\user32.dll";
Assert.AreEqual(@"C:\Windows\System32\user32.dll", link.Path);
}
[Test]
public void TestShowCmd()
{
ShellLink link = new ShellLink();
link.ShowCmd = ShellLink.ShowCommand.ShowMinimized;
Assert.AreEqual(ShellLink.ShowCommand.ShowMinimized, link.ShowCmd);
}
[Test]
public void TestWorkingDirectory()
{
ShellLink link = new ShellLink();
link.WorkingDirectory = null;
Assert.AreEqual("", link.WorkingDirectory);
link.WorkingDirectory = @"C:\";
Assert.AreEqual(@"C:\", link.WorkingDirectory);
}
[Test]
public void TestSaveLoad()
{
{
ShellLink link = new ShellLink();
link.Path = @"%SystemRoot%\System32\kernel32.dll";
link.Description = "Windows\' kernel API";
link.Save(System.IO.Path.Combine(testFolderPath, "kernel32.lnk"));
}
{
ShellLink link = new ShellLink();
link.Load(System.IO.Path.Combine(testFolderPath, "kernel32.lnk"));
Assert.AreEqual(System.IO.Path.Combine(Environment.SystemDirectory, "kernel32.dll").ToLower(), link.Path.ToLower());
Assert.AreEqual("Windows\' kernel API", link.Description);
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I'm a system administrator from Moscow, Russia. Programming is one of my hobbies. I presume I'm one of the first Russians who created a Web site dedicated to .Net known that time as NGWS. However, the Web page has been abandoned a long ago.