Consolidated test file reference to TestCaseSources

pull/83/head
David Hall 2019-09-17 10:36:00 -06:00
parent 4d434826b4
commit d086778902
35 changed files with 160 additions and 147 deletions

View File

@ -10,6 +10,38 @@ namespace Vanara.PInvoke.Tests
{ {
public static class TestCaseSources public static class TestCaseSources
{ {
public const string BmpFile = @"C:\Temp\Vanara.bmp";
public const string EventFile = @"C:\Temp\TestLogFile.etl";
public const string IcoFile = @"C:\Temp\Vanara.ico";
public const string ImageFile = @"C:\Temp\Vanara.png";
public const string Image2File = @"C:\Temp\X.png";
public const string LargeFile = @"C:\Temp\Holes.mp4";
public const string LogFile = @"C:\Temp\Test.log";
public const string ResourceFile = @"C:\Temp\DummyResourceExe.exe";
public const string SmallFile = IcoFile;
public const string TempChildDir = @"C:\Temp\Temp";
public const string TempChildDirWhack = TempChildDir + "\\";
public const string TempDir = @"C:\Temp";
public const string TempDirWhack = TempDir + "\\";
public const string VirtualDisk = @"D:\VirtualBox VMs\Windows Client\Windows XP Pro\Windows XP Pro.vhd";
public const string WordDoc = @"C:\Temp\Test.docx";
public const string WordDocLink = @"C:\Temp\Test.lnk";
// Header: ValidUser ValidCred URN DN DC Domain Username Password Notes // Header: ValidUser ValidCred URN DN DC Domain Username Password Notes
private const string authfn = @"C:\Temp\AuthTestCases.txt"; private const string authfn = @"C:\Temp\AuthTestCases.txt";
@ -37,15 +69,6 @@ namespace Vanara.PInvoke.Tests
return ret; return ret;
} }
} }
public static string LargeFile => @"C:\Temp\Holes.mp4";
public static string LogFile => @"C:\Temp\TestLogFile.etl";
public static string ResourceFile => @"C:\Temp\DummyResourceExe.exe";
public static string SmallFile => @"C:\Temp\Help.ico";
public static string TempChildDir => @"C:\Temp\Temp";
public static string TempDir => @"C:\Temp";
public static string WordDoc => @"C:\Temp\Test.docx";
public static object[] GetAuthCasesFromFile(bool validUser, bool validCred) => AuthCasesFromFile.Where(objs => ((object[])objs)[0].Equals(validUser) && ((object[])objs)[1].Equals(validCred)).ToArray(); public static object[] GetAuthCasesFromFile(bool validUser, bool validCred) => AuthCasesFromFile.Where(objs => ((object[])objs)[0].Equals(validUser) && ((object[])objs)[1].Equals(validCred)).ToArray();
public static IEnumerable<TestCaseData> RemoteConnections(bool? named) public static IEnumerable<TestCaseData> RemoteConnections(bool? named)

View File

@ -56,7 +56,7 @@ namespace Vanara.PInvoke.Tests
[Test] [Test]
public void CreateDirectoryTest() public void CreateDirectoryTest()
{ {
const string dir = @"C:\Temp\Temp"; const string dir = TestCaseSources.TempChildDir;
Assert.That(CreateDirectory(dir), Is.True); Assert.That(CreateDirectory(dir), Is.True);
Assert.That(System.IO.Directory.Exists(dir), Is.True); Assert.That(System.IO.Directory.Exists(dir), Is.True);
Assert.That(RemoveDirectory(dir), Is.True); Assert.That(RemoveDirectory(dir), Is.True);
@ -113,7 +113,7 @@ namespace Vanara.PInvoke.Tests
public void DefineDosDeviceTest() public void DefineDosDeviceTest()
{ {
const string src = "M:"; const string src = "M:";
const string target = @"C:\Temp"; const string target = TestCaseSources.TempDir;
var c = QueryDosDevice(src).ToArray().Length; var c = QueryDosDevice(src).ToArray().Length;
Assert.That(DefineDosDevice(DDD.DDD_NO_BROADCAST_SYSTEM, src, target), Is.True); Assert.That(DefineDosDevice(DDD.DDD_NO_BROADCAST_SYSTEM, src, target), Is.True);
@ -159,7 +159,7 @@ namespace Vanara.PInvoke.Tests
var thread = new Thread(FileMaker); var thread = new Thread(FileMaker);
try try
{ {
using (var h = FindFirstChangeNotification(@"C:\Temp", false, FILE_NOTIFY_CHANGE.FILE_NOTIFY_CHANGE_FILE_NAME)) using (var h = FindFirstChangeNotification(TestCaseSources.TempDir, false, FILE_NOTIFY_CHANGE.FILE_NOTIFY_CHANGE_FILE_NAME))
{ {
Assert.That(h.IsInvalid, Is.False); Assert.That(h.IsInvalid, Is.False);
thread.Start(); thread.Start();
@ -176,7 +176,7 @@ namespace Vanara.PInvoke.Tests
void FileMaker() void FileMaker()
{ {
const string fn = @"C:\Temp\_tempFile.txt"; const string fn = TestCaseSources.TempDir + @"\_tempFile.txt";
while (keepGoing) while (keepGoing)
{ {
Thread.Sleep(200); Thread.Sleep(200);

View File

@ -11,7 +11,7 @@ namespace Vanara.PInvoke.Tests
[TestFixture] [TestFixture]
public class Kernel32Tests public class Kernel32Tests
{ {
internal const string fn = @"C:\Temp\help.ico"; internal const string fn = TestCaseSources.SmallFile;
internal const string tmpstr = @"Temporary"; internal const string tmpstr = @"Temporary";
public static string CreateTempFile(bool markAsTemp = true) public static string CreateTempFile(bool markAsTemp = true)

View File

@ -20,7 +20,7 @@ namespace Vanara.PInvoke.Tests
[Test] [Test]
public void AddRemoveDllDirectoryTest() public void AddRemoveDllDirectoryTest()
{ {
var ptr = AddDllDirectory(@"C:\Temp"); var ptr = AddDllDirectory(TestCaseSources.TempDir);
Assert.That(ptr, Is.Not.EqualTo(IntPtr.Zero)); Assert.That(ptr, Is.Not.EqualTo(IntPtr.Zero));
Assert.That(RemoveDllDirectory(ptr), Is.True); Assert.That(RemoveDllDirectory(ptr), Is.True);
} }

View File

@ -45,41 +45,41 @@ namespace Vanara.PInvoke.Tests
[Test] [Test]
public void PathCchAddBackslashTest() public void PathCchAddBackslashTest()
{ {
var sb = new StringBuilder(@"C:\Temp\", 100); var sb = new StringBuilder(TestCaseSources.TempDirWhack, 100);
Assert.That(PathCchAddBackslash(sb, sb.Capacity), Is.EqualTo((HRESULT)HRESULT.S_FALSE)); Assert.That(PathCchAddBackslash(sb, sb.Capacity), Is.EqualTo((HRESULT)HRESULT.S_FALSE));
Assert.That(sb.ToString(), Is.EqualTo(@"C:\Temp\")); Assert.That(sb.ToString(), Is.EqualTo(TestCaseSources.TempDirWhack));
sb = new StringBuilder(@"C:\Temp", 100); sb = new StringBuilder(TestCaseSources.TempDir, 100);
Assert.That(PathCchAddBackslash(sb, sb.Capacity), Is.EqualTo((HRESULT)0)); Assert.That(PathCchAddBackslash(sb, sb.Capacity), Is.EqualTo((HRESULT)0));
Assert.That(sb.ToString(), Is.EqualTo(@"C:\Temp\")); Assert.That(sb.ToString(), Is.EqualTo(TestCaseSources.TempDirWhack));
} }
[Test] [Test]
public void PathCchAddBackslashExTest() public void PathCchAddBackslashExTest()
{ {
var sb = new StringBuilder(@"C:\Temp\", 64); var sb = new StringBuilder(TestCaseSources.TempDirWhack, 64);
Assert.That(PathCchAddBackslashEx(sb, sb.Capacity, out var end, out var rem), Is.EqualTo((HRESULT)HRESULT.S_FALSE)); Assert.That(PathCchAddBackslashEx(sb, sb.Capacity, out var end, out var rem), Is.EqualTo((HRESULT)HRESULT.S_FALSE));
Assert.That(sb.ToString(), Is.EqualTo(@"C:\Temp\")); Assert.That(sb.ToString(), Is.EqualTo(TestCaseSources.TempDirWhack));
Assert.That(end, Is.Not.EqualTo(IntPtr.Zero)); Assert.That(end, Is.Not.EqualTo(IntPtr.Zero));
Assert.That(rem, Is.LessThan(60)); Assert.That(rem, Is.LessThan(60));
sb = new StringBuilder(@"C:\Temp", 64); sb = new StringBuilder(TestCaseSources.TempDir, 64);
Assert.That(PathCchAddBackslashEx(sb, sb.Capacity, out end, out rem), Is.EqualTo((HRESULT)0)); Assert.That(PathCchAddBackslashEx(sb, sb.Capacity, out end, out rem), Is.EqualTo((HRESULT)0));
Assert.That(sb.ToString(), Is.EqualTo(@"C:\Temp\")); Assert.That(sb.ToString(), Is.EqualTo(TestCaseSources.TempDirWhack));
Assert.That(rem, Is.LessThan(60)); Assert.That(rem, Is.LessThan(60));
} }
[Test] [Test]
public void PathCchAddBackslashExTest2() public void PathCchAddBackslashExTest2()
{ {
var sb = new SafeCoTaskMemString(@"C:\Temp\", 64); var sb = new SafeCoTaskMemString(TestCaseSources.TempDirWhack, 64);
Assert.That(PathCchAddBackslashEx((IntPtr)sb, sb.Capacity, out var end, out var rem), Is.EqualTo((HRESULT)HRESULT.S_FALSE)); Assert.That(PathCchAddBackslashEx((IntPtr)sb, sb.Capacity, out var end, out var rem), Is.EqualTo((HRESULT)HRESULT.S_FALSE));
Assert.That(sb.ToString(), Is.EqualTo(@"C:\Temp\")); Assert.That(sb.ToString(), Is.EqualTo(TestCaseSources.TempDirWhack));
Assert.That(end, Is.EqualTo(sb.DangerousGetHandle().Offset(sb.Length * 2))); Assert.That(end, Is.EqualTo(sb.DangerousGetHandle().Offset(sb.Length * 2)));
sb = new SafeCoTaskMemString(@"C:\Temp", 64); sb = new SafeCoTaskMemString(TestCaseSources.TempDir, 64);
Assert.That(PathCchAddBackslashEx((IntPtr)sb, sb.Size, out end, out rem), Is.EqualTo((HRESULT)0)); Assert.That(PathCchAddBackslashEx((IntPtr)sb, sb.Size, out end, out rem), Is.EqualTo((HRESULT)0));
Assert.That(sb.ToString(), Is.EqualTo(@"C:\Temp\")); Assert.That(sb.ToString(), Is.EqualTo(TestCaseSources.TempDirWhack));
Assert.That(end, Is.EqualTo(sb.DangerousGetHandle().Offset(sb.Length * 2))); Assert.That(end, Is.EqualTo(sb.DangerousGetHandle().Offset(sb.Length * 2)));
} }
@ -156,26 +156,26 @@ namespace Vanara.PInvoke.Tests
[Test] [Test]
public void PathCchRemoveBackslashTest() public void PathCchRemoveBackslashTest()
{ {
var sb = new StringBuilder(@"C:\Temp\", 64); var sb = new StringBuilder(TestCaseSources.TempDirWhack, 64);
Assert.That(PathCchRemoveBackslash(sb, sb.Capacity), Is.EqualTo((HRESULT)0)); Assert.That(PathCchRemoveBackslash(sb, sb.Capacity), Is.EqualTo((HRESULT)0));
Assert.That(sb.ToString(), Is.EqualTo(@"C:\Temp")); Assert.That(sb.ToString(), Is.EqualTo(TestCaseSources.TempDir));
sb = new StringBuilder(@"C:\Temp", 64); sb = new StringBuilder(TestCaseSources.TempDir, 64);
Assert.That(PathCchRemoveBackslash(sb, sb.Capacity), Is.EqualTo((HRESULT)HRESULT.S_FALSE)); Assert.That(PathCchRemoveBackslash(sb, sb.Capacity), Is.EqualTo((HRESULT)HRESULT.S_FALSE));
Assert.That(sb.ToString(), Is.EqualTo(@"C:\Temp")); Assert.That(sb.ToString(), Is.EqualTo(TestCaseSources.TempDir));
} }
[Test] [Test]
public void PathCchRemoveBackslashExTest() public void PathCchRemoveBackslashExTest()
{ {
var sb = new SafeCoTaskMemString(@"C:\Temp\", 64); var sb = new SafeCoTaskMemString(TestCaseSources.TempDirWhack, 64);
Assert.That(PathCchRemoveBackslashEx((IntPtr)sb, sb.Capacity, out var end, out var rem), Is.EqualTo((HRESULT)0)); Assert.That(PathCchRemoveBackslashEx((IntPtr)sb, sb.Capacity, out var end, out var rem), Is.EqualTo((HRESULT)0));
Assert.That(sb.ToString(), Is.EqualTo(@"C:\Temp")); Assert.That(sb.ToString(), Is.EqualTo(TestCaseSources.TempDir));
Assert.That(end, Is.EqualTo(sb.DangerousGetHandle().Offset(14))); Assert.That(end, Is.EqualTo(sb.DangerousGetHandle().Offset(14)));
sb = new SafeCoTaskMemString(@"C:\Temp", 64); sb = new SafeCoTaskMemString(TestCaseSources.TempDir, 64);
Assert.That(PathCchRemoveBackslashEx((IntPtr)sb, sb.Capacity, out end, out rem), Is.EqualTo((HRESULT)HRESULT.S_FALSE)); Assert.That(PathCchRemoveBackslashEx((IntPtr)sb, sb.Capacity, out end, out rem), Is.EqualTo((HRESULT)HRESULT.S_FALSE));
Assert.That(sb.ToString(), Is.EqualTo(@"C:\Temp")); Assert.That(sb.ToString(), Is.EqualTo(TestCaseSources.TempDir));
Assert.That(end, Is.EqualTo(sb.DangerousGetHandle().Offset(14))); Assert.That(end, Is.EqualTo(sb.DangerousGetHandle().Offset(14)));
} }
@ -214,7 +214,7 @@ namespace Vanara.PInvoke.Tests
[Test] [Test]
public void PathCchSkipRootTest() public void PathCchSkipRootTest()
{ {
var sb = new SafeCoTaskMemString(@"C:\Temp\", 64); var sb = new SafeCoTaskMemString(TestCaseSources.TempDirWhack, 64);
Assert.That(PathCchSkipRoot((IntPtr)sb, out var end), Is.EqualTo((HRESULT)0)); Assert.That(PathCchSkipRoot((IntPtr)sb, out var end), Is.EqualTo((HRESULT)0));
Assert.That(end, Is.EqualTo(sb.DangerousGetHandle().Offset(6))); Assert.That(end, Is.EqualTo(sb.DangerousGetHandle().Offset(6)));
} }

View File

@ -40,11 +40,11 @@ namespace Vanara.PInvoke.Tests
Assert.That(sb.ToString().StartsWith("C:")); Assert.That(sb.ToString().StartsWith("C:"));
TestContext.WriteLine(sb); TestContext.WriteLine(sb);
Assert.That(SetCurrentDirectory(@"C:\Temp"), Is.True); Assert.That(SetCurrentDirectory(TestCaseSources.TempDir), Is.True);
var sb2 = new StringBuilder(MAX_PATH); var sb2 = new StringBuilder(MAX_PATH);
Assert.That(GetCurrentDirectory((uint)sb2.Capacity, sb2), Is.GreaterThan(0)); Assert.That(GetCurrentDirectory((uint)sb2.Capacity, sb2), Is.GreaterThan(0));
Assert.That(sb2.ToString(), Is.EqualTo(@"C:\Temp")); Assert.That(sb2.ToString(), Is.EqualTo(TestCaseSources.TempDir));
Assert.That(SetCurrentDirectory(sb.ToString())); Assert.That(SetCurrentDirectory(sb.ToString()));
} }

View File

@ -65,7 +65,7 @@ namespace Vanara.PInvoke.Tests
Assert.That(SetThreadpoolTimerEx(timer, FileDueTime, 0, 0), Is.False); Assert.That(SetThreadpoolTimerEx(timer, FileDueTime, 0, 0), Is.False);
Assert.That(IsThreadpoolTimerSet(timer), Is.True); Assert.That(IsThreadpoolTimerSet(timer), Is.True);
using (var hFile = CreateFile(@"C:\Temp\help.ico", FileAccess.FILE_GENERIC_READ, System.IO.FileShare.Read, null, System.IO.FileMode.Open, FileFlagsAndAttributes.FILE_FLAG_OVERLAPPED)) using (var hFile = CreateFile(TestCaseSources.SmallFile, FileAccess.FILE_GENERIC_READ, System.IO.FileShare.Read, null, System.IO.FileMode.Open, FileFlagsAndAttributes.FILE_FLAG_OVERLAPPED))
using (var io = CreateThreadpoolIo(hFile, MyIoCallback, default, CallBackEnviron)) using (var io = CreateThreadpoolIo(hFile, MyIoCallback, default, CallBackEnviron))
{ {
Assert.That(io, ResultIs.ValidHandle); Assert.That(io, ResultIs.ValidHandle);

View File

@ -16,8 +16,8 @@ namespace Vanara.PInvoke.Tests
[TestFixture] [TestFixture]
public partial class WinBaseTests_File public partial class WinBaseTests_File
{ {
private const string bigfn = @"C:\Temp\Holes.mp4"; private const string bigfn = TestCaseSources.LargeFile;
private const string fn = @"C:\Temp\help.ico"; private const string fn = TestCaseSources.SmallFile;
private const string newfn = @"C:\Temp\help2.ico"; private const string newfn = @"C:\Temp\help2.ico";
[Test] [Test]
@ -68,8 +68,8 @@ namespace Vanara.PInvoke.Tests
[Test] [Test]
public void CreateDirectoryExTest() public void CreateDirectoryExTest()
{ {
Assert.That(CreateDirectoryEx(@"C:\Temp", @"C:\Temp\NewDir"), ResultIs.Successful); Assert.That(CreateDirectoryEx(TestCaseSources.TempDir, TestCaseSources.TempChildDir), ResultIs.Successful);
Assert.That(RemoveDirectory(@"C:\Temp\NewDir"), ResultIs.Successful); Assert.That(RemoveDirectory(TestCaseSources.TempChildDir), ResultIs.Successful);
} }
[Test] [Test]
@ -105,7 +105,7 @@ namespace Vanara.PInvoke.Tests
public void EnumVolumeMountPointsTest() public void EnumVolumeMountPointsTest()
{ {
// Setup a new mount on C: // Setup a new mount on C:
const string mntDir = @"C:\Temp\Mounted\"; const string mntDir = TestCaseSources.TempDirWhack + @"Mounted\";
var sb = new StringBuilder(100); var sb = new StringBuilder(100);
Assert.That(GetVolumeNameForVolumeMountPoint(@"C:\", sb, (uint)sb.Capacity), ResultIs.Successful); Assert.That(GetVolumeNameForVolumeMountPoint(@"C:\", sb, (uint)sb.Capacity), ResultIs.Successful);
var cvol = sb.ToString(); var cvol = sb.ToString();
@ -140,7 +140,7 @@ namespace Vanara.PInvoke.Tests
public void GetFileInformationByHandleExTest() public void GetFileInformationByHandleExTest()
{ {
using (var tmp = new TempFile(FileAccess.GENERIC_READ, FileShare.Read)) using (var tmp = new TempFile(FileAccess.GENERIC_READ, FileShare.Read))
using (var hDir = CreateFile(@"C:\Temp\", FileAccess.GENERIC_READ, FileShare.Read, null, FileMode.Open, FileFlagsAndAttributes.FILE_FLAG_BACKUP_SEMANTICS)) using (var hDir = CreateFile(TestCaseSources.TempDirWhack, FileAccess.GENERIC_READ, FileShare.Read, null, FileMode.Open, FileFlagsAndAttributes.FILE_FLAG_BACKUP_SEMANTICS))
{ {
var exes = new List<Exception>(); var exes = new List<Exception>();
TestHelper.RunForEach<FILE_INFO_BY_HANDLE_CLASS>(typeof(Kernel32), "GetFileInformationByHandleEx", e => new object[] { IsDir(e) ? (HFILE)hDir : (HFILE)tmp.hFile, e }, TestHelper.RunForEach<FILE_INFO_BY_HANDLE_CLASS>(typeof(Kernel32), "GetFileInformationByHandleEx", e => new object[] { IsDir(e) ? (HFILE)hDir : (HFILE)tmp.hFile, e },
@ -167,7 +167,7 @@ namespace Vanara.PInvoke.Tests
[Test] [Test]
public void MoveFileExTest() public void MoveFileExTest()
{ {
const string newFld = @"C:\Temp\Temp\"; const string newFld = TestCaseSources.TempChildDir;
Assert.That(MoveFileEx(fn, Path.Combine(newFld, Path.GetFileName(fn)), MOVEFILE.MOVEFILE_REPLACE_EXISTING), ResultIs.Successful); Assert.That(MoveFileEx(fn, Path.Combine(newFld, Path.GetFileName(fn)), MOVEFILE.MOVEFILE_REPLACE_EXISTING), ResultIs.Successful);
Assert.That(MoveFileEx(Path.Combine(newFld, Path.GetFileName(fn)), fn, MOVEFILE.MOVEFILE_REPLACE_EXISTING), ResultIs.Successful); Assert.That(MoveFileEx(Path.Combine(newFld, Path.GetFileName(fn)), fn, MOVEFILE.MOVEFILE_REPLACE_EXISTING), ResultIs.Successful);
} }
@ -175,7 +175,7 @@ namespace Vanara.PInvoke.Tests
[Test] [Test]
public void MoveFileTest() public void MoveFileTest()
{ {
const string newFld = @"C:\Temp\Temp\"; const string newFld = TestCaseSources.TempChildDir;
Assert.That(MoveFile(fn, Path.Combine(newFld, Path.GetFileName(fn))), ResultIs.Successful); Assert.That(MoveFile(fn, Path.Combine(newFld, Path.GetFileName(fn))), ResultIs.Successful);
Assert.That(MoveFile(Path.Combine(newFld, Path.GetFileName(fn)), fn), ResultIs.Successful); Assert.That(MoveFile(Path.Combine(newFld, Path.GetFileName(fn)), fn), ResultIs.Successful);
} }
@ -183,7 +183,7 @@ namespace Vanara.PInvoke.Tests
[Test] [Test]
public void MoveFileWithProgressTest() public void MoveFileWithProgressTest()
{ {
const string newFld = @"C:\Temp\Temp\"; const string newFld = TestCaseSources.TempChildDir;
var qtr = 0; var qtr = 0;
Assert.That(MoveFileWithProgress(bigfn, Path.Combine(newFld, Path.GetFileName(bigfn)), fProgress, default, MOVEFILE.MOVEFILE_REPLACE_EXISTING), ResultIs.Successful); Assert.That(MoveFileWithProgress(bigfn, Path.Combine(newFld, Path.GetFileName(bigfn)), fProgress, default, MOVEFILE.MOVEFILE_REPLACE_EXISTING), ResultIs.Successful);
Assert.That(MoveFileWithProgress(Path.Combine(newFld, Path.GetFileName(bigfn)), bigfn, fProgress, default, MOVEFILE.MOVEFILE_REPLACE_EXISTING), ResultIs.Successful); Assert.That(MoveFileWithProgress(Path.Combine(newFld, Path.GetFileName(bigfn)), bigfn, fProgress, default, MOVEFILE.MOVEFILE_REPLACE_EXISTING), ResultIs.Successful);
@ -209,7 +209,7 @@ namespace Vanara.PInvoke.Tests
public unsafe void ReadDirectoryChangesExWTest() public unsafe void ReadDirectoryChangesExWTest()
{ {
var newFile = Path.Combine(Path.GetDirectoryName(fn), "X.ico"); var newFile = Path.Combine(Path.GetDirectoryName(fn), "X.ico");
using (var hDir = CreateFile(@"C:\Temp\", FileAccess.GENERIC_READ, FileShare.Read, null, FileMode.Open, FileFlagsAndAttributes.FILE_FLAG_BACKUP_SEMANTICS)) using (var hDir = CreateFile(TestCaseSources.TempDirWhack, FileAccess.GENERIC_READ, FileShare.Read, null, FileMode.Open, FileFlagsAndAttributes.FILE_FLAG_BACKUP_SEMANTICS))
using (var mem = new SafeHGlobalHandle(4096)) using (var mem = new SafeHGlobalHandle(4096))
{ {
new Thread(() => { Sleep(100); DeleteFile(newFile); CopyFile(fn, newFile, false); DeleteFile(newFile); }).Start(); new Thread(() => { Sleep(100); DeleteFile(newFile); CopyFile(fn, newFile, false); DeleteFile(newFile); }).Start();
@ -237,7 +237,7 @@ namespace Vanara.PInvoke.Tests
public void ReadDirectoryChangesTest() public void ReadDirectoryChangesTest()
{ {
var newFile = Path.Combine(Path.GetDirectoryName(fn), "X.ico"); var newFile = Path.Combine(Path.GetDirectoryName(fn), "X.ico");
using (var hDir = CreateFile(@"C:\Temp\", FileAccess.GENERIC_READ, FileShare.Read, null, FileMode.Open, FileFlagsAndAttributes.FILE_FLAG_BACKUP_SEMANTICS)) using (var hDir = CreateFile(TestCaseSources.TempDirWhack, FileAccess.GENERIC_READ, FileShare.Read, null, FileMode.Open, FileFlagsAndAttributes.FILE_FLAG_BACKUP_SEMANTICS))
using (var mem = new SafeHGlobalHandle(4096)) using (var mem = new SafeHGlobalHandle(4096))
{ {
new Thread(() => { Sleep(100); DeleteFile(newFile); CopyFile(fn, newFile, false); DeleteFile(newFile); }).Start(); new Thread(() => { Sleep(100); DeleteFile(newFile); CopyFile(fn, newFile, false); DeleteFile(newFile); }).Start();
@ -276,7 +276,7 @@ namespace Vanara.PInvoke.Tests
public void ReplaceFileTest() public void ReplaceFileTest()
{ {
Assert.That(CopyFile(fn, newfn, false), ResultIs.Successful); Assert.That(CopyFile(fn, newfn, false), ResultIs.Successful);
Assert.That(ReplaceFile(newfn, @"C:\Temp\tsnew.ico"), ResultIs.Successful); Assert.That(ReplaceFile(newfn, TestCaseSources.BmpFile), ResultIs.Successful);
Assert.That(DeleteFile(newfn), ResultIs.Successful); Assert.That(DeleteFile(newfn), ResultIs.Successful);
} }

View File

@ -6,7 +6,7 @@ namespace Vanara.PInvoke.Tests
[TestFixture] [TestFixture]
public partial class WinBaseTests_Resource public partial class WinBaseTests_Resource
{ {
private const string ResExe = @"C:\Temp\DummyResourceExe.exe"; private const string ResExe = TestCaseSources.ResourceFile;
private const int ResId1 = 103; private const int ResId1 = 103;
private const int ResId2 = 129; private const int ResId2 = 129;
private const int ResType = (int)ResourceType.RT_DIALOG; private const int ResType = (int)ResourceType.RT_DIALOG;

View File

@ -9,9 +9,10 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Vanara.PInvoke.Tests</RootNamespace> <RootNamespace>Vanara.PInvoke.Tests</RootNamespace>
<AssemblyName>UnitTest.PInvoke.NTDSApi</AssemblyName> <AssemblyName>UnitTest.PInvoke.NTDSApi</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -62,6 +63,10 @@
<Project>{a5e519e9-feba-4fe3-93a5-b8269bef72f4}</Project> <Project>{a5e519e9-feba-4fe3-93a5-b8269bef72f4}</Project>
<Name>Vanara.PInvoke.Shared</Name> <Name>Vanara.PInvoke.Shared</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\CSharpRunner\Shared.csproj">
<Project>{a96cff10-0967-429a-8700-4a86c97c5603}</Project>
<Name>Shared</Name>
</ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@ -14,27 +14,6 @@ namespace Vanara.PInvoke.Tests
public SafeDsHandle hDs; public SafeDsHandle hDs;
public string dn; public string dn;
internal static object[] AuthCasesFromFile
{
get
{
const string authfn = @"C:\Temp\AuthTestCases.txt";
var lines = File.ReadAllLines(authfn).Skip(1).Where(s => !string.IsNullOrWhiteSpace(s)).ToArray();
var ret = new object[lines.Length];
for (var i = 0; i < lines.Length; i++)
{
var items = lines[i].Split('\t').Select(s => s == string.Empty ? null : s).Cast<object>().ToArray();
if (items.Length < 9) continue;
bool.TryParse(items[0].ToString(), out var validUser);
items[0] = validUser;
bool.TryParse(items[1].ToString(), out var validCred);
items[1] = validCred;
ret[i] = items;
}
return ret;
}
}
[OneTimeSetUp] [OneTimeSetUp]
public void Setup() public void Setup()
{ {
@ -42,7 +21,7 @@ namespace Vanara.PInvoke.Tests
DsBind(null, dn, out hDs).ThrowIfFailed(); DsBind(null, dn, out hDs).ThrowIfFailed();
} }
[Test, TestCaseSource(typeof(NTDSApiTests), nameof(NTDSApiTests.AuthCasesFromFile))] [Test, TestCaseSource(typeof(TestCaseSources), nameof(TestCaseSources.AuthCasesFromFile))]
public void DsBindTest(bool validUser, bool validCred, string urn, string dn, string dcn, string domain, string un, string pwd, string notes) public void DsBindTest(bool validUser, bool validCred, string urn, string dn, string dcn, string domain, string un, string pwd, string notes)
{ {
Assert.That(DsBind(dcn, dn, out var dsb).Succeeded && !dsb.IsInvalid, Is.EqualTo(validUser)); Assert.That(DsBind(dcn, dn, out var dsb).Succeeded && !dsb.IsInvalid, Is.EqualTo(validUser));
@ -50,7 +29,7 @@ namespace Vanara.PInvoke.Tests
Assert.That(DsBind(null, dn, out var dsb2).Succeeded && !dsb2.IsInvalid, Is.EqualTo(validUser)); Assert.That(DsBind(null, dn, out var dsb2).Succeeded && !dsb2.IsInvalid, Is.EqualTo(validUser));
} }
[Test, TestCaseSource(typeof(NTDSApiTests), nameof(NTDSApiTests.AuthCasesFromFile))] [Test, TestCaseSource(typeof(TestCaseSources), nameof(TestCaseSources.AuthCasesFromFile))]
public void DsBindByInstanceTest(bool validUser, bool validCred, string urn, string dn, string dcn, string domain, string un, string pwd, string notes) public void DsBindByInstanceTest(bool validUser, bool validCred, string urn, string dn, string dcn, string domain, string un, string pwd, string notes)
{ {
Assert.That(DsBindByInstance(DnsDomainName: dn, AuthIdentity: SafeAuthIdentityHandle.LocalThreadIdentity, phDS: out var dsb).Succeeded && !dsb.IsInvalid, Is.EqualTo(validUser)); Assert.That(DsBindByInstance(DnsDomainName: dn, AuthIdentity: SafeAuthIdentityHandle.LocalThreadIdentity, phDS: out var dsb).Succeeded && !dsb.IsInvalid, Is.EqualTo(validUser));
@ -62,7 +41,7 @@ namespace Vanara.PInvoke.Tests
Assert.That(DsBindToISTG(null, out var dsb).Succeeded && !dsb.IsInvalid, Is.True); Assert.That(DsBindToISTG(null, out var dsb).Succeeded && !dsb.IsInvalid, Is.True);
} }
[Test, TestCaseSource(typeof(NTDSApiTests), nameof(NTDSApiTests.AuthCasesFromFile))] [Test, TestCaseSource(typeof(TestCaseSources), nameof(TestCaseSources.AuthCasesFromFile))]
public void DsBindWithCredTest(bool validUser, bool validCred, string urn, string dn, string dcn, string domain, string un, string pwd, string notes) public void DsBindWithCredTest(bool validUser, bool validCred, string urn, string dn, string dcn, string domain, string un, string pwd, string notes)
{ {
void Meth() void Meth()
@ -76,7 +55,7 @@ namespace Vanara.PInvoke.Tests
Assert.That(Meth, Throws.Nothing); Assert.That(Meth, Throws.Nothing);
} }
[Test, TestCaseSource(typeof(NTDSApiTests), nameof(NTDSApiTests.AuthCasesFromFile))] [Test, TestCaseSource(typeof(TestCaseSources), nameof(TestCaseSources.AuthCasesFromFile))]
public void DsCrackNamesTest(bool validUser, bool validCred, string urn, string dn, string dc, string domain, string un, string pwd, string notes) public void DsCrackNamesTest(bool validUser, bool validCred, string urn, string dn, string dc, string domain, string un, string pwd, string notes)
{ {
var res = DsCrackNames(hDs, new[] {un}, DS_NAME_FORMAT.DS_NT4_ACCOUNT_NAME); var res = DsCrackNames(hDs, new[] {un}, DS_NAME_FORMAT.DS_NT4_ACCOUNT_NAME);

View File

@ -9,9 +9,10 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Vanara.PInvoke.Tests</RootNamespace> <RootNamespace>Vanara.PInvoke.Tests</RootNamespace>
<AssemblyName>UnitTest.PInvoke.Ole</AssemblyName> <AssemblyName>UnitTest.PInvoke.Ole</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -64,6 +65,10 @@
<Project>{30fd6779-6549-449e-880a-695815eb89b0}</Project> <Project>{30fd6779-6549-449e-880a-695815eb89b0}</Project>
<Name>Vanara.PInvoke.ShlwApi</Name> <Name>Vanara.PInvoke.ShlwApi</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\CSharpRunner\Shared.csproj">
<Project>{a96cff10-0967-429a-8700-4a86c97c5603}</Project>
<Name>Shared</Name>
</ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@ -213,7 +213,7 @@ namespace Vanara.PInvoke.Tests
/*public void GetCF() /*public void GetCF()
{ {
foreach (var f in Directory.EnumerateFiles(@"C:\Temp", "*.*", SearchOption.AllDirectories)) foreach (var f in Directory.EnumerateFiles(TestCaseSources.TempDir, "*.*", SearchOption.AllDirectories))
{ {
try try
{ {
@ -273,7 +273,7 @@ namespace Vanara.PInvoke.Tests
StgCreateStorageEx(Path.GetTempFileName(), STGM.STGM_DELETEONRELEASE | STGM.STGM_CREATE | STGM.STGM_DIRECT | STGM.STGM_READWRITE | STGM.STGM_SHARE_EXCLUSIVE, STGFMT.STGFMT_DOCFILE, 0, IntPtr.Zero, IntPtr.Zero, typeof(IStorage).GUID, out var iptr); StgCreateStorageEx(Path.GetTempFileName(), STGM.STGM_DELETEONRELEASE | STGM.STGM_CREATE | STGM.STGM_DIRECT | STGM.STGM_READWRITE | STGM.STGM_SHARE_EXCLUSIVE, STGFMT.STGFMT_DOCFILE, 0, IntPtr.Zero, IntPtr.Zero, typeof(IStorage).GUID, out var iptr);
return (IStorage)iptr; return (IStorage)iptr;
case VARTYPE.VT_STREAM: case VARTYPE.VT_STREAM:
SHCreateStreamOnFileEx(@"C:\Temp\Help.ico", STGM.STGM_READ | STGM.STGM_SHARE_EXCLUSIVE, 0, false, null, out var stm); SHCreateStreamOnFileEx(TestCaseSources.SmallFile, STGM.STGM_READ | STGM.STGM_SHARE_EXCLUSIVE, 0, false, null, out var stm);
return stm; return stm;
case VARTYPE.VT_UNKNOWN: case VARTYPE.VT_UNKNOWN:
return Activator.CreateInstance(Type.GetTypeFromProgID("ADODB.Error")); return Activator.CreateInstance(Type.GetTypeFromProgID("ADODB.Error"));

View File

@ -137,7 +137,7 @@ namespace Vanara.PInvoke.Tests
using (new ElevPriv("SeSecurityPrivilege")) using (new ElevPriv("SeSecurityPrivilege"))
{ {
Assert.That(GetNamedSecurityInfo(AdvApi32Tests.fn, SE_OBJECT_TYPE.SE_FILE_OBJECT, SecInfoAll, out var pOwnSid, out var pGrpSid, out var dacl, out var sacl, out var plsd), ResultIs.Successful); Assert.That(GetNamedSecurityInfo(AdvApi32Tests.fn, SE_OBJECT_TYPE.SE_FILE_OBJECT, SecInfoAll, out var pOwnSid, out var pGrpSid, out var dacl, out var sacl, out var plsd), ResultIs.Successful);
Assert.That(TreeResetNamedSecurityInfo(@"C:\Temp\Temp\", SE_OBJECT_TYPE.SE_FILE_OBJECT, SecInfoAll, pOwnSid, pGrpSid, dacl, sacl, false, OnProgress, PROG_INVOKE_SETTING.ProgressInvokeEveryObject), ResultIs.Successful); Assert.That(TreeResetNamedSecurityInfo(TestCaseSources.TempChildDirWhack, SE_OBJECT_TYPE.SE_FILE_OBJECT, SecInfoAll, pOwnSid, pGrpSid, dacl, sacl, false, OnProgress, PROG_INVOKE_SETTING.ProgressInvokeEveryObject), ResultIs.Successful);
} }
Assert.That(counter, Is.GreaterThan(0)); Assert.That(counter, Is.GreaterThan(0));
@ -151,7 +151,7 @@ namespace Vanara.PInvoke.Tests
using (new ElevPriv("SeSecurityPrivilege")) using (new ElevPriv("SeSecurityPrivilege"))
{ {
Assert.That(GetNamedSecurityInfo(AdvApi32Tests.fn, SE_OBJECT_TYPE.SE_FILE_OBJECT, SecInfoAll, out var pOwnSid, out var pGrpSid, out var dacl, out var sacl, out var plsd), ResultIs.Successful); Assert.That(GetNamedSecurityInfo(AdvApi32Tests.fn, SE_OBJECT_TYPE.SE_FILE_OBJECT, SecInfoAll, out var pOwnSid, out var pGrpSid, out var dacl, out var sacl, out var plsd), ResultIs.Successful);
Assert.That(TreeSetNamedSecurityInfo(@"C:\Temp\Temp\", SE_OBJECT_TYPE.SE_FILE_OBJECT, SecInfoAll, pOwnSid, pGrpSid, dacl, sacl, TREE_SEC_INFO.TREE_SEC_INFO_SET, OnProgress, PROG_INVOKE_SETTING.ProgressInvokeEveryObject), ResultIs.Successful); Assert.That(TreeSetNamedSecurityInfo(TestCaseSources.TempChildDirWhack, SE_OBJECT_TYPE.SE_FILE_OBJECT, SecInfoAll, pOwnSid, pGrpSid, dacl, sacl, TREE_SEC_INFO.TREE_SEC_INFO_SET, OnProgress, PROG_INVOKE_SETTING.ProgressInvokeEveryObject), ResultIs.Successful);
} }
Assert.That(counter, Is.GreaterThan(0)); Assert.That(counter, Is.GreaterThan(0));

View File

@ -19,30 +19,7 @@ namespace Vanara.PInvoke.Tests
public class AdvApi32Tests public class AdvApi32Tests
{ {
internal const SECURITY_INFORMATION AllSI = SECURITY_INFORMATION.OWNER_SECURITY_INFORMATION | SECURITY_INFORMATION.GROUP_SECURITY_INFORMATION | SECURITY_INFORMATION.DACL_SECURITY_INFORMATION | SECURITY_INFORMATION.SACL_SECURITY_INFORMATION; internal const SECURITY_INFORMATION AllSI = SECURITY_INFORMATION.OWNER_SECURITY_INFORMATION | SECURITY_INFORMATION.GROUP_SECURITY_INFORMATION | SECURITY_INFORMATION.DACL_SECURITY_INFORMATION | SECURITY_INFORMATION.SACL_SECURITY_INFORMATION;
internal const string fn = @"C:\Temp\help.ico"; internal const string fn = TestCaseSources.SmallFile;
internal static object[] GetAuthCasesFromFile(bool validUser, bool validCred) => AuthCasesFromFile.Where(objs => ((object[])objs)[0].Equals(validUser) && ((object[])objs)[1].Equals(validCred)).ToArray();
internal static object[] AuthCasesFromFile
{
get
{
const string authfn = @"C:\Temp\AuthTestCases.txt";
var lines = File.ReadAllLines(authfn).Skip(1).Where(s => !string.IsNullOrWhiteSpace(s)).ToArray();
var ret = new object[lines.Length];
for (var i = 0; i < lines.Length; i++)
{
var items = lines[i].Split('\t').Select(s => s == string.Empty ? null : s).Cast<object>().ToArray();
if (items.Length < 9) continue;
bool.TryParse(items[0].ToString(), out var validUser);
items[0] = validUser;
bool.TryParse(items[1].ToString(), out var validCred);
items[1] = validCred;
ret[i] = items;
}
return ret;
}
}
[Test()] [Test()]
public void ConvertSecurityDescriptorToStringSecurityDescriptorTest() public void ConvertSecurityDescriptorToStringSecurityDescriptorTest()

View File

@ -15,7 +15,7 @@ namespace Vanara.PInvoke.Tests
[TestFixture()] [TestFixture()]
public partial class EvnTraceTests public partial class EvnTraceTests
{ {
private const string logfilePath = @"C:\Temp\TestLogFile.etl"; private const string logfilePath = TestCaseSources.EventFile;
[Test] [Test]
public void EnumerateTraceGuidsTest() public void EnumerateTraceGuidsTest()

View File

@ -12,7 +12,7 @@ namespace Vanara.PInvoke.Tests
using (new ElevPriv("SeSecurityPrivilege")) using (new ElevPriv("SeSecurityPrivilege"))
{ {
var si = SECURITY_INFORMATION.OWNER_SECURITY_INFORMATION | SECURITY_INFORMATION.GROUP_SECURITY_INFORMATION | SECURITY_INFORMATION.DACL_SECURITY_INFORMATION | SECURITY_INFORMATION.SACL_SECURITY_INFORMATION; var si = SECURITY_INFORMATION.OWNER_SECURITY_INFORMATION | SECURITY_INFORMATION.GROUP_SECURITY_INFORMATION | SECURITY_INFORMATION.DACL_SECURITY_INFORMATION | SECURITY_INFORMATION.SACL_SECURITY_INFORMATION;
Assert.That(GetNamedSecurityInfo(@"C:\Temp\help.ico", SE_OBJECT_TYPE.SE_FILE_OBJECT, si, out _, out _, out _, out _, out var sd), ResultIs.Successful); Assert.That(GetNamedSecurityInfo(TestCaseSources.SmallFile, SE_OBJECT_TYPE.SE_FILE_OBJECT, si, out _, out _, out _, out _, out var sd), ResultIs.Successful);
string sd_sddl; string sd_sddl;
using (sd) using (sd)
{ {

View File

@ -412,7 +412,7 @@ namespace Vanara.PInvoke.Tests
Assert.That(FindFirstFreeAce(acl, out var pAce), ResultIs.Successful); Assert.That(FindFirstFreeAce(acl, out var pAce), ResultIs.Successful);
} }
[Test, TestCaseSource(typeof(AdvApi32Tests), nameof(AdvApi32Tests.AuthCasesFromFile))] [Test, TestCaseSource(typeof(TestCaseSources), nameof(TestCaseSources.AuthCasesFromFile))]
public void GetAceTest(bool validUser, bool validCred, string urn, string dn, string dc, string domain, string username, string password, string notes) public void GetAceTest(bool validUser, bool validCred, string urn, string dn, string dc, string domain, string username, string password, string notes)
{ {
var fun = $"{domain}\\{username}"; var fun = $"{domain}\\{username}";

View File

@ -114,7 +114,7 @@ namespace Vanara.PInvoke.Tests
(uint)FileAccess.FILE_GENERIC_READ, SafePSID.Everyone, "(exists Administrator)", out var ret), ResultIs.Successful); (uint)FileAccess.FILE_GENERIC_READ, SafePSID.Everyone, "(exists Administrator)", out var ret), ResultIs.Successful);
} }
[Test, TestCaseSource(typeof(AdvApi32Tests), nameof(AdvApi32Tests.GetAuthCasesFromFile), new object[] { true, true })] [Test, TestCaseSource(typeof(TestCaseSources), nameof(TestCaseSources.GetAuthCasesFromFile), new object[] { true, true })]
public void CreateProcessWithLogonWTest(bool validUser, bool validCred, string urn, string dn, string dc, string domain, string username, string password, string notes) public void CreateProcessWithLogonWTest(bool validUser, bool validCred, string urn, string dn, string dc, string domain, string username, string password, string notes)
{ {
var sti = new STARTUPINFO { ShowWindowCommand = ShowWindowCommand.SW_SHOWMINIMIZED }; var sti = new STARTUPINFO { ShowWindowCommand = ShowWindowCommand.SW_SHOWMINIMIZED };
@ -216,7 +216,7 @@ namespace Vanara.PInvoke.Tests
Assert.That(isUni.HasFlag(IS_TEXT_UNICODE.IS_TEXT_UNICODE_ASCII16)); Assert.That(isUni.HasFlag(IS_TEXT_UNICODE.IS_TEXT_UNICODE_ASCII16));
} }
[Test, TestCaseSource(typeof(AdvApi32Tests), nameof(AdvApi32Tests.AuthCasesFromFile))] [Test, TestCaseSource(typeof(TestCaseSources), nameof(TestCaseSources.AuthCasesFromFile))]
public void LogonUserExTest(bool validUser, bool validCred, string urn, string dn, string dcn, string domain, string un, string pwd, string notes) public void LogonUserExTest(bool validUser, bool validCred, string urn, string dn, string dcn, string domain, string un, string pwd, string notes)
{ {
Assert.That(LogonUserEx(urn, null, pwd, LogonUserType.LOGON32_LOGON_INTERACTIVE, LogonUserProvider.LOGON32_PROVIDER_DEFAULT, out var hTok, out var pSid, Assert.That(LogonUserEx(urn, null, pwd, LogonUserType.LOGON32_LOGON_INTERACTIVE, LogonUserProvider.LOGON32_PROVIDER_DEFAULT, out var hTok, out var pSid,
@ -226,7 +226,7 @@ namespace Vanara.PInvoke.Tests
buf.Dispose(); buf.Dispose();
} }
[Test, TestCaseSource(typeof(AdvApi32Tests), nameof(AdvApi32Tests.AuthCasesFromFile))] [Test, TestCaseSource(typeof(TestCaseSources), nameof(TestCaseSources.AuthCasesFromFile))]
public void LogonUserExExTest(bool validUser, bool validCred, string urn, string dn, string dcn, string domain, string un, string pwd, string notes) public void LogonUserExExTest(bool validUser, bool validCred, string urn, string dn, string dcn, string domain, string un, string pwd, string notes)
{ {
using (new ElevPriv("SeTcbPrivilege")) using (new ElevPriv("SeTcbPrivilege"))
@ -243,7 +243,7 @@ namespace Vanara.PInvoke.Tests
} }
} }
[Test, TestCaseSource(typeof(AdvApi32Tests), nameof(AdvApi32Tests.AuthCasesFromFile))] [Test, TestCaseSource(typeof(TestCaseSources), nameof(TestCaseSources.AuthCasesFromFile))]
public void LogonUserTest(bool validUser, bool validCred, string urn, string dn, string dcn, string domain, string un, string pwd, string notes) public void LogonUserTest(bool validUser, bool validCred, string urn, string dn, string dcn, string domain, string un, string pwd, string notes)
{ {
Assert.That(LogonUser(urn, null, pwd, LogonUserType.LOGON32_LOGON_INTERACTIVE, LogonUserProvider.LOGON32_PROVIDER_DEFAULT, out var hTok), Assert.That(LogonUser(urn, null, pwd, LogonUserType.LOGON32_LOGON_INTERACTIVE, LogonUserProvider.LOGON32_PROVIDER_DEFAULT, out var hTok),
@ -251,7 +251,7 @@ namespace Vanara.PInvoke.Tests
hTok.Dispose(); hTok.Dispose();
} }
[Test, TestCaseSource(typeof(AdvApi32Tests), nameof(AdvApi32Tests.AuthCasesFromFile))] [Test, TestCaseSource(typeof(TestCaseSources), nameof(TestCaseSources.AuthCasesFromFile))]
public void LookupAccountNameSidTest(bool validUser, bool validCred, string urn, string dn, string dc, string domain, string username, string password, string notes) public void LookupAccountNameSidTest(bool validUser, bool validCred, string urn, string dn, string dc, string domain, string username, string password, string notes)
{ {
var fun = $"{domain}\\{username}"; var fun = $"{domain}\\{username}";

View File

@ -11,7 +11,7 @@ namespace Vanara.PInvoke.Tests
[TestFixture()] [TestFixture()]
public class WinBase_EventLogTests public class WinBase_EventLogTests
{ {
private const string eventLogName = @"C:\Temp\Test.log"; private const string eventLogName = TestCaseSources.LogFile;
[Test] [Test]
public void OpenBackupClearCloseEventLogTest() public void OpenBackupClearCloseEventLogTest()

View File

@ -85,7 +85,7 @@ namespace Vanara.PInvoke.Tests
[Test] [Test]
public void EncryptionDisableTest() public void EncryptionDisableTest()
{ {
var dir = System.IO.Path.Combine(@"C:\Temp\", System.IO.Path.GetRandomFileName()); var dir = System.IO.Path.Combine(TestCaseSources.TempDirWhack, System.IO.Path.GetRandomFileName());
var dirInfo = System.IO.Directory.CreateDirectory(dir); var dirInfo = System.IO.Directory.CreateDirectory(dir);
try try
{ {

View File

@ -105,7 +105,7 @@ namespace Vanara.PInvoke.Tests
using (var hRM = GetAuthzInitializeResourceManager()) using (var hRM = GetAuthzInitializeResourceManager())
using (var hCtx = GetCurrentUserAuthContext(hRM)) using (var hCtx = GetCurrentUserAuthContext(hRM))
using (var hEvt = GetAuthzInitializeObjectAccessAuditEvent()) using (var hEvt = GetAuthzInitializeObjectAccessAuditEvent())
using (var psd = AdvApi32Tests.GetSD(@"C:\Temp\help.ico")) using (var psd = AdvApi32Tests.GetSD(TestCaseSources.SmallFile))
using (var reply = new AUTHZ_ACCESS_REPLY(1)) using (var reply = new AUTHZ_ACCESS_REPLY(1))
{ {
var req = new AUTHZ_ACCESS_REQUEST((uint)ACCESS_MASK.MAXIMUM_ALLOWED); var req = new AUTHZ_ACCESS_REQUEST((uint)ACCESS_MASK.MAXIMUM_ALLOWED);
@ -286,7 +286,7 @@ namespace Vanara.PInvoke.Tests
using (var hRM = GetAuthzInitializeResourceManager()) using (var hRM = GetAuthzInitializeResourceManager())
using (var hCtx = GetCurrentUserAuthContext(hRM)) using (var hCtx = GetCurrentUserAuthContext(hRM))
using (var hEvt = GetAuthzInitializeObjectAccessAuditEvent()) using (var hEvt = GetAuthzInitializeObjectAccessAuditEvent())
using (var psd = AdvApi32Tests.GetSD(@"C:\Temp\help.ico")) using (var psd = AdvApi32Tests.GetSD(TestCaseSources.SmallFile))
using (var reply = new AUTHZ_ACCESS_REPLY(1)) using (var reply = new AUTHZ_ACCESS_REPLY(1))
{ {
var req = new AUTHZ_ACCESS_REQUEST((uint)ACCESS_MASK.MAXIMUM_ALLOWED); var req = new AUTHZ_ACCESS_REQUEST((uint)ACCESS_MASK.MAXIMUM_ALLOWED);

View File

@ -44,7 +44,7 @@ namespace Vanara.PInvoke.Tests
Assert.That(blob.Length, Is.EqualTo(blobSize)); Assert.That(blob.Length, Is.EqualTo(blobSize));
} }
[Test, TestCaseSource(typeof(AdvApi32Tests), nameof(AdvApi32Tests.GetAuthCasesFromFile), new object[] { true, true })] [Test, TestCaseSource(typeof(TestCaseSources), nameof(TestCaseSources.GetAuthCasesFromFile), new object[] { true, true })]
public void SspiTest(bool validUser, bool validCred, string urn, string dn, string dc, string domain, string username, string password, string notes) public void SspiTest(bool validUser, bool validCred, string urn, string dn, string dc, string domain, string username, string password, string notes)
{ {
var save = false; var save = false;

View File

@ -15,7 +15,7 @@ namespace Vanara.PInvoke.Tests
[Test] [Test]
public void ExtractAssociatedIconTest() public void ExtractAssociatedIconTest()
{ {
const string icoFile = @"C:\Temp\Test.docx"; const string icoFile = TestCaseSources.WordDoc;
var sb = new StringBuilder(icoFile, MAX_PATH); var sb = new StringBuilder(icoFile, MAX_PATH);
ushort iidx = 0; ushort iidx = 0;
using (var hIcon = ExtractAssociatedIcon(HINSTANCE.NULL, sb, ref iidx)) using (var hIcon = ExtractAssociatedIcon(HINSTANCE.NULL, sb, ref iidx))
@ -26,7 +26,7 @@ namespace Vanara.PInvoke.Tests
[Test] [Test]
public void ExtractAssociatedIconExTest() public void ExtractAssociatedIconExTest()
{ {
const string icoFile = @"C:\Temp\Test.docx"; const string icoFile = TestCaseSources.WordDoc;
var sb = new StringBuilder(icoFile, MAX_PATH); var sb = new StringBuilder(icoFile, MAX_PATH);
ushort iidx = 0, iid = 0; ushort iidx = 0, iid = 0;
using (var hIcon = ExtractAssociatedIconEx(HINSTANCE.NULL, sb, ref iidx, ref iid)) using (var hIcon = ExtractAssociatedIconEx(HINSTANCE.NULL, sb, ref iidx, ref iid))

View File

@ -9,9 +9,10 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Vanara.PInvoke.Tests</RootNamespace> <RootNamespace>Vanara.PInvoke.Tests</RootNamespace>
<AssemblyName>UnitTest.PInvoke.Shell32</AssemblyName> <AssemblyName>UnitTest.PInvoke.Shell32</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -63,6 +64,10 @@
<Project>{a6771907-addc-49fc-8444-a97aa65e77e2}</Project> <Project>{a6771907-addc-49fc-8444-a97aa65e77e2}</Project>
<Name>Vanara.PInvoke.User32</Name> <Name>Vanara.PInvoke.User32</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\CSharpRunner\Shared.csproj">
<Project>{a96cff10-0967-429a-8700-4a86c97c5603}</Project>
<Name>Shared</Name>
</ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="NUnit"> <PackageReference Include="NUnit">

View File

@ -9,9 +9,10 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Vanara.PInvoke.Tests</RootNamespace> <RootNamespace>Vanara.PInvoke.Tests</RootNamespace>
<AssemblyName>UnitTest.PInvoke.User32</AssemblyName> <AssemblyName>UnitTest.PInvoke.User32</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -67,6 +68,10 @@
<Project>{a6771907-addc-49fc-8444-a97aa65e77e2}</Project> <Project>{a6771907-addc-49fc-8444-a97aa65e77e2}</Project>
<Name>Vanara.PInvoke.User32</Name> <Name>Vanara.PInvoke.User32</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\CSharpRunner\Shared.csproj">
<Project>{a96cff10-0967-429a-8700-4a86c97c5603}</Project>
<Name>Shared</Name>
</ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@ -312,7 +312,7 @@ namespace Vanara.PInvoke.Tests
// Try set string value // Try set string value
var sb = new System.Text.StringBuilder(Kernel32.MAX_PATH, Kernel32.MAX_PATH); var sb = new System.Text.StringBuilder(Kernel32.MAX_PATH, Kernel32.MAX_PATH);
Assert.That(SystemParametersInfo(SPI.SPI_GETDESKWALLPAPER, (uint)sb.Capacity, sb, 0)); Assert.That(SystemParametersInfo(SPI.SPI_GETDESKWALLPAPER, (uint)sb.Capacity, sb, 0));
var wp = @"C:\Temp\tsnew256.png"; var wp = TestCaseSources.ImageFile;
Assert.That(SystemParametersInfo(SPI.SPI_SETDESKWALLPAPER, (uint)wp.Length, wp, SPIF.SPIF_SENDCHANGE)); Assert.That(SystemParametersInfo(SPI.SPI_SETDESKWALLPAPER, (uint)wp.Length, wp, SPIF.SPIF_SENDCHANGE));
Assert.That(SystemParametersInfo(SPI.SPI_SETDESKWALLPAPER, (uint)sb.Length, sb.ToString(), SPIF.SPIF_SENDCHANGE)); Assert.That(SystemParametersInfo(SPI.SPI_SETDESKWALLPAPER, (uint)sb.Length, sb.ToString(), SPIF.SPIF_SENDCHANGE));
} }

View File

@ -9,9 +9,10 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Vanara.System.Tests</RootNamespace> <RootNamespace>Vanara.System.Tests</RootNamespace>
<AssemblyName>UnitTest.System</AssemblyName> <AssemblyName>UnitTest.System</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -102,6 +103,10 @@
<Project>{eeec146d-14b2-4eef-9155-e1aef82d85f6}</Project> <Project>{eeec146d-14b2-4eef-9155-e1aef82d85f6}</Project>
<Name>Vanara.SystemServices</Name> <Name>Vanara.SystemServices</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\CSharpRunner\Shared.csproj">
<Project>{a96cff10-0967-429a-8700-4a86c97c5603}</Project>
<Name>Shared</Name>
</ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@ -12,9 +12,9 @@ namespace Vanara.IO.Tests
[TestFixture()] [TestFixture()]
public class VirtualDiskTests public class VirtualDiskTests
{ {
const string tmpfn = @"C:\Temp\TestVHD.vhd"; const string tmpfn = Vanara.PInvoke.Tests.TestCaseSources.TempDirWhack + "TestVHD.vhd";
const string tmpcfn = @"C:\Temp\TestVHD-Diff.vhd"; const string tmpcfn = Vanara.PInvoke.Tests.TestCaseSources.TempDirWhack + "TestVHD - Diff.vhd";
const string fn = @"D:\VirtualBox VMs\Windows Client\Windows XP Pro\Windows XP Pro.vhd"; const string fn = Vanara.PInvoke.Tests.TestCaseSources.VirtualDisk;
[Test()] [Test()]
public void CreateDynPropTest() public void CreateDynPropTest()
@ -148,7 +148,7 @@ namespace Vanara.IO.Tests
Assert.That(vhd.ParentIdentifier, Is.Not.EqualTo(Guid.Empty)); // must be differencing Assert.That(vhd.ParentIdentifier, Is.Not.EqualTo(Guid.Empty)); // must be differencing
Assert.That(vhd.ParentPaths, Is.Null); // must be differencing Assert.That(vhd.ParentPaths, Is.Null); // must be differencing
Assert.That(vhd.ParentTimeStamp, Is.Zero); // must be differencing Assert.That(vhd.ParentTimeStamp, Is.Zero); // must be differencing
//TestContext.WriteLine(vhd.PhysicalPath); // must be attached //TestContext.WriteLine(vhd.PhysicalPath); // must be attached
Assert.That(vhd.PhysicalSectorSize, Is.EqualTo(0x200)); Assert.That(vhd.PhysicalSectorSize, Is.EqualTo(0x200));
Assert.That(vhd.PhysicalSize, Is.LessThan(sz)); Assert.That(vhd.PhysicalSize, Is.LessThan(sz));
Assert.That(vhd.ProviderSubtype, Is.EqualTo(VirtualDisk.Subtype.Differencing)); Assert.That(vhd.ProviderSubtype, Is.EqualTo(VirtualDisk.Subtype.Differencing));

View File

@ -19,10 +19,10 @@ namespace Vanara.Windows.Forms.Tests
var dlg = new AccessControlEditorDialog() { ElevationRequired = true, OwnerElevationRequired = true, AllowEditOwner = true }; var dlg = new AccessControlEditorDialog() { ElevationRequired = true, OwnerElevationRequired = true, AllowEditOwner = true };
//dlg.Flags = SI_OBJECT_INFO_Flags.SI_EDIT_OWNER | SI_OBJECT_INFO_Flags.SI_EDIT_AUDITS | SI_OBJECT_INFO_Flags.SI_ADVANCED | SI_OBJECT_INFO_Flags.SI_RESET | SI_OBJECT_INFO_Flags.SI_EDIT_PROPERTIES | SI_OBJECT_INFO_Flags.SI_EDIT_EFFECTIVE | SI_OBJECT_INFO_Flags.SI_RESET_SACL; //dlg.Flags = SI_OBJECT_INFO_Flags.SI_EDIT_OWNER | SI_OBJECT_INFO_Flags.SI_EDIT_AUDITS | SI_OBJECT_INFO_Flags.SI_ADVANCED | SI_OBJECT_INFO_Flags.SI_RESET | SI_OBJECT_INFO_Flags.SI_EDIT_PROPERTIES | SI_OBJECT_INFO_Flags.SI_EDIT_EFFECTIVE | SI_OBJECT_INFO_Flags.SI_RESET_SACL;
//dlg.ResourceType = AccessControlEditorDialog.TaskResourceType; dlg.ObjectName = @"AUScheduledInstall"; //dlg.ResourceType = AccessControlEditorDialog.TaskResourceType; dlg.ObjectName = @"AUScheduledInstall";
dlg.Initialize(new System.IO.FileInfo(@"C:\Temp\help.ico")); dlg.Initialize(new System.IO.FileInfo(Vanara.PInvoke.Tests.TestCaseSources.SmallFile));
dlg.ShowDialog(); dlg.ShowDialog();
dlg.Initialize(new System.IO.DirectoryInfo(@"C:\Temp")); dlg.Initialize(new System.IO.DirectoryInfo(Vanara.PInvoke.Tests.TestCaseSources.TempDir));
dlg.ShowDialog(); dlg.ShowDialog();
dlg.Initialize(Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Console")); dlg.Initialize(Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Console"));

View File

@ -24,7 +24,7 @@ namespace Vanara.Windows.Forms.Tests
public void ImageListFromHandleTest() public void ImageListFromHandleTest()
{ {
var himl = ImageList_Create(32, 32, ILC.ILC_COLOR32 | ILC.ILC_MASK, 8, 8); var himl = ImageList_Create(32, 32, ILC.ILC_COLOR32 | ILC.ILC_MASK, 8, 8);
himl.Interface.Add(new Gdi32.SafeHBITMAP((Image.FromFile(@"C:\Temp\TriggerTypeLogon.png", true) as Bitmap).GetHbitmap()), HBITMAP.NULL); himl.Interface.Add(new Gdi32.SafeHBITMAP((Image.FromFile(Vanara.PInvoke.Tests.TestCaseSources.ImageFile, true) as Bitmap).GetHbitmap()), HBITMAP.NULL);
Assert.That(himl.IsNull, Is.False); Assert.That(himl.IsNull, Is.False);
var il2 = ImageListExtension.ToImageList(himl); var il2 = ImageListExtension.ToImageList(himl);
Assert.That(il2.HandleCreated, Is.True); Assert.That(il2.HandleCreated, Is.True);
@ -37,9 +37,9 @@ namespace Vanara.Windows.Forms.Tests
public void AddOverlayAndDrawTest() public void AddOverlayAndDrawTest()
{ {
var il = new ImageList() { ColorDepth = ColorDepth.Depth32Bit, ImageSize = new Size(32, 32) }; var il = new ImageList() { ColorDepth = ColorDepth.Depth32Bit, ImageSize = new Size(32, 32) };
il.Images.Add(new Icon(@"C:\Temp\help.ico")); il.Images.Add(new Icon(Vanara.PInvoke.Tests.TestCaseSources.SmallFile));
Assert.That(il.Images.Count, Is.EqualTo(1)); Assert.That(il.Images.Count, Is.EqualTo(1));
var ovIdx = il.AddOverlay(new Bitmap(@"C:\Temp\overlay32.png"), Color.Transparent); var ovIdx = il.AddOverlay(new Bitmap(Vanara.PInvoke.Tests.TestCaseSources.Image2File), Color.Transparent);
Assert.That(il.Images.Count, Is.EqualTo(2)); Assert.That(il.Images.Count, Is.EqualTo(2));
var bmp = new Bitmap(32, 32, System.Drawing.Imaging.PixelFormat.Format32bppArgb); var bmp = new Bitmap(32, 32, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
using (var g = Graphics.FromImage(bmp)) using (var g = Graphics.FromImage(bmp))
@ -52,12 +52,12 @@ namespace Vanara.Windows.Forms.Tests
{ {
var il = new ImageList() { ColorDepth = ColorDepth.Depth32Bit, ImageSize = new Size(32, 32) }; var il = new ImageList() { ColorDepth = ColorDepth.Depth32Bit, ImageSize = new Size(32, 32) };
il.SetBackgroundColor(Color.Transparent); il.SetBackgroundColor(Color.Transparent);
var img1 = Image.FromFile(@"C:\Temp\tsnew32.png", true); var img1 = Image.FromFile(Vanara.PInvoke.Tests.TestCaseSources.ImageFile, true);
il.Images.Add(img1, Color.Transparent); il.Images.Add(img1, Color.Transparent);
ShowImage(il.Images[0]); ShowImage(il.Images[0]);
var il2 = new ImageList() { ColorDepth = ColorDepth.Depth32Bit, ImageSize = new Size(32, 32) }; var il2 = new ImageList() { ColorDepth = ColorDepth.Depth32Bit, ImageSize = new Size(32, 32) };
il2.SetBackgroundColor(Color.Transparent); il2.SetBackgroundColor(Color.Transparent);
var img2 = Image.FromFile(@"C:\Temp\TriggerTypeLogon.png", true); var img2 = Image.FromFile(Vanara.PInvoke.Tests.TestCaseSources.Image2File, true);
il2.Images.Add(img2, Color.Transparent); il2.Images.Add(img2, Color.Transparent);
ShowImage(il2.Images[0]); ShowImage(il2.Images[0]);
var ico = il.MergeImage(0, il2, 0); var ico = il.MergeImage(0, il2, 0);
@ -73,7 +73,7 @@ namespace Vanara.Windows.Forms.Tests
frm.KeyDown += (s, e) => frm.BackColor = Color.Red; frm.KeyDown += (s, e) => frm.BackColor = Color.Red;
frm.Controls.Add(pbox); frm.Controls.Add(pbox);
if (timeOut > 0) if (timeOut > 0)
frm.Shown += (s,e) => FormTimeout(); frm.Shown += (s, e) => FormTimeout();
frm.ShowDialog(); frm.ShowDialog();
void FormTimeout() void FormTimeout()

View File

@ -9,9 +9,10 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Vanara.Windows.Forms.Tests</RootNamespace> <RootNamespace>Vanara.Windows.Forms.Tests</RootNamespace>
<AssemblyName>UnitTest.Windows.Forms</AssemblyName> <AssemblyName>UnitTest.Windows.Forms</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -112,6 +113,10 @@
<Project>{43685be2-a65e-4b01-be16-479526940f23}</Project> <Project>{43685be2-a65e-4b01-be16-479526940f23}</Project>
<Name>Vanara.Windows.Shell</Name> <Name>Vanara.Windows.Shell</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\CSharpRunner\Shared.csproj">
<Project>{a96cff10-0967-429a-8700-4a86c97c5603}</Project>
<Name>Shared</Name>
</ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@ -84,7 +84,7 @@ namespace Vanara.Windows.Shell.Tests
progid.CLSID = null; progid.CLSID = null;
Assert.That(progid.CLSID, Is.Null); Assert.That(progid.CLSID, Is.Null);
var i = new IconLocation(@"C:\Temp\dllexp.exe", -1); var i = new IconLocation(Vanara.PInvoke.Tests.TestCaseSources.ResourceFile, -1);
progid.DefaultIcon = i; progid.DefaultIcon = i;
Assert.That(progid.DefaultIcon.ToString(), Is.EqualTo(i.ToString())); Assert.That(progid.DefaultIcon.ToString(), Is.EqualTo(i.ToString()));
progid.DefaultIcon = null; progid.DefaultIcon = null;
@ -96,7 +96,7 @@ namespace Vanara.Windows.Shell.Tests
progid.EditFlags = 0; progid.EditFlags = 0;
Assert.That(progid.EditFlags, Is.EqualTo(PInvoke.ShlwApi.FILETYPEATTRIBUTEFLAGS.FTA_None)); Assert.That(progid.EditFlags, Is.EqualTo(PInvoke.ShlwApi.FILETYPEATTRIBUTEFLAGS.FTA_None));
var fn = new IndirectString(@"C:\Temp\dllexp.exe", -1); var fn = new IndirectString(Vanara.PInvoke.Tests.TestCaseSources.ResourceFile, -1);
progid.FriendlyTypeName = fn; progid.FriendlyTypeName = fn;
Assert.That(progid.FriendlyTypeName.ToString(), Is.EqualTo(fn.ToString())); Assert.That(progid.FriendlyTypeName.ToString(), Is.EqualTo(fn.ToString()));
progid.FriendlyTypeName = null; progid.FriendlyTypeName = null;
@ -110,7 +110,7 @@ namespace Vanara.Windows.Shell.Tests
var vopen = progid.Verbs.Add("Open", "&Open", "notepad.exe %1"); var vopen = progid.Verbs.Add("Open", "&Open", "notepad.exe %1");
var vprint = progid.Verbs.Add("Print", "&Print", "notepad.exe %1"); var vprint = progid.Verbs.Add("Print", "&Print", "notepad.exe %1");
var vend = progid.Verbs.Add("Terminate", "&End", "notepad.exe %1"); var vend = progid.Verbs.Add("Terminate", "&End", "notepad.exe %1");
progid.Verbs.Order = new[] {vend, vprint}; progid.Verbs.Order = new[] { vend, vprint };
} }
} }
} }

View File

@ -14,8 +14,8 @@ namespace Vanara.Windows.Shell.Tests
public class ShellItemTests public class ShellItemTests
{ {
internal const string badTestDoc = @"C:\Temp\BadTest.doc"; internal const string badTestDoc = @"C:\Temp\BadTest.doc";
internal const string testDoc = @"C:\Temp\Test.docx"; internal const string testDoc = Vanara.PInvoke.Tests.TestCaseSources.WordDoc;
internal const string testLinkDoc = @"C:\Temp\Test.lnk"; internal const string testLinkDoc = Vanara.PInvoke.Tests.TestCaseSources.WordDocLink;
[Test] [Test]
public void ShellItemTest1() public void ShellItemTest1()
@ -206,7 +206,7 @@ namespace Vanara.Windows.Shell.Tests
[Test] [Test]
public void GetHandlerTest2() public void GetHandlerTest2()
{ {
using (var shellItem = new ShellItem(@"C:\Temp\Holes.mp4")) using (var shellItem = new ShellItem(Vanara.PInvoke.Tests.TestCaseSources.LargeFile))
{ {
if (!shellItem.IsFolder) if (!shellItem.IsFolder)
TestContext.WriteLine(shellItem.Properties[PROPERTYKEY.System.MIMEType]); TestContext.WriteLine(shellItem.Properties[PROPERTYKEY.System.MIMEType]);
@ -226,7 +226,7 @@ namespace Vanara.Windows.Shell.Tests
Assert.That(bmp, Is.Not.Null); Assert.That(bmp, Is.Not.Null);
Assert.That(bmp.Size, Is.EqualTo(sz)); Assert.That(bmp.Size, Is.EqualTo(sz));
} }
using (var i = new ShellItem(@"C:\Temp\IDA256.png")) using (var i = new ShellItem(Vanara.PInvoke.Tests.TestCaseSources.ImageFile))
{ {
var sz = new System.Drawing.Size(1024, 1024); var sz = new System.Drawing.Size(1024, 1024);
var bmp = i.GetImage(sz, ShellItemGetImageOptions.ThumbnailOnly | ShellItemGetImageOptions.ScaleUp); var bmp = i.GetImage(sz, ShellItemGetImageOptions.ThumbnailOnly | ShellItemGetImageOptions.ScaleUp);

View File

@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Vanara.Windows.Shell.Tests</RootNamespace> <RootNamespace>Vanara.Windows.Shell.Tests</RootNamespace>
<AssemblyName>UnitTest.Windows.Shell</AssemblyName> <AssemblyName>UnitTest.Windows.Shell</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion> <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<TargetFrameworkProfile /> <TargetFrameworkProfile />
@ -82,6 +82,10 @@
<Project>{43685be2-a65e-4b01-be16-479526940f23}</Project> <Project>{43685be2-a65e-4b01-be16-479526940f23}</Project>
<Name>Vanara.Windows.Shell</Name> <Name>Vanara.Windows.Shell</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\CSharpRunner\Shared.csproj">
<Project>{a96cff10-0967-429a-8700-4a86c97c5603}</Project>
<Name>Shared</Name>
</ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.