Updated unit tests with changes to library

pull/10/head
David Hall 2017-12-22 09:08:36 -07:00
parent 4c0d2feeaa
commit 02eaec5c12
4 changed files with 25 additions and 9 deletions

View File

@ -70,7 +70,7 @@ namespace Vanara.InteropServices.Tests
Assert.That(() => ms.Poke(ba, -1), Throws.TypeOf<ArgumentOutOfRangeException>());
ms.Poke(ba, 1);
Assert.That(ms.Read<int>(), Is.EqualTo(0x00000102));
Assert.That(() => ms.Read<Vanara.PInvoke.User32.ICONINFO>(), Throws.TypeOf<ArgumentOutOfRangeException>());
Assert.That(() => ms.Read<Vanara.PInvoke.User32_Gdi.ICONINFO>(), Throws.TypeOf<ArgumentOutOfRangeException>());
}
}
@ -125,7 +125,7 @@ namespace Vanara.InteropServices.Tests
Assert.That(() => ms.Write(bytes, -1, 8), Throws.TypeOf<ArgumentOutOfRangeException>());
Assert.That(() => ms.Write(bytes, 1, -8), Throws.TypeOf<ArgumentOutOfRangeException>());
Assert.That(() => ms.Write(new byte[22]), Throws.ArgumentException);
Assert.That(() => ms.Write(new Vanara.PInvoke.User32.ICONINFO()), Throws.ArgumentException);
Assert.That(() => ms.Write(new Vanara.PInvoke.User32_Gdi.ICONINFO()), Throws.ArgumentException);
ms.Write((SafeHGlobalHandle) null);
Assert.That(ms.Position, Is.Zero);
ms.Write((string[]) null);

View File

@ -193,12 +193,12 @@ namespace Vanara.PInvoke.Tests
[Test()]
public void GetTokenInformationTest()
{
//var p = SafeTokenHandle.CurrentProcessToken.GetConvertedInfo<PTOKEN_PRIVILEGES>(TOKEN_INFORMATION_CLASS.TokenPrivileges).Privileges;
//var p = SafeTokenHandle.CurrentProcessToken.GetInfo<PTOKEN_PRIVILEGES>(TOKEN_INFORMATION_CLASS.TokenPrivileges).Privileges;
using (var t = SafeTokenHandle.FromProcess(GetCurrentProcess(), TokenAccess.TOKEN_QUERY))
{
Assert.That(t, Is.Not.Null);
var p = t.GetConvertedInfo<PTOKEN_PRIVILEGES>(TOKEN_INFORMATION_CLASS.TokenPrivileges);
var p = t.GetInfo<PTOKEN_PRIVILEGES>(TOKEN_INFORMATION_CLASS.TokenPrivileges);
Assert.That(p, Is.Not.Null);
Assert.That(p.PrivilegeCount, Is.GreaterThan(0));
TestContext.WriteLine("Privs: " + string.Join("; ", p.Privileges.Select(i => i.ToString())));
@ -216,18 +216,18 @@ namespace Vanara.PInvoke.Tests
using (var t = SafeTokenHandle.FromThread(GetCurrentThread(), TokenAccess.TOKEN_QUERY))
{
var id = t.GetConvertedInfo<uint>(TOKEN_INFORMATION_CLASS.TokenSessionId);
var id = t.GetInfo<uint>(TOKEN_INFORMATION_CLASS.TokenSessionId);
Assert.That(id, Is.Not.Zero);
TestContext.WriteLine($"SessId: {id}");
var ve = t.GetConvertedInfo<bool>(TOKEN_INFORMATION_CLASS.TokenVirtualizationEnabled);
var ve = t.GetInfo<bool>(TOKEN_INFORMATION_CLASS.TokenVirtualizationEnabled);
TestContext.WriteLine($"VirtEnable: {ve}");
var et = t.GetConvertedInfo<TOKEN_ELEVATION_TYPE>(TOKEN_INFORMATION_CLASS.TokenElevationType);
var et = t.GetInfo<TOKEN_ELEVATION_TYPE>(TOKEN_INFORMATION_CLASS.TokenElevationType);
Assert.That(et, Is.Not.Zero);
TestContext.WriteLine($"ElevType: {et}");
var e = t.GetConvertedInfo<TOKEN_ELEVATION>(TOKEN_INFORMATION_CLASS.TokenElevation);
var e = t.GetInfo<TOKEN_ELEVATION>(TOKEN_INFORMATION_CLASS.TokenElevation);
Assert.That(e, Is.Not.Zero);
TestContext.WriteLine($"Elev: {e.TokenIsElevated}");
}

View File

@ -8,7 +8,7 @@ using Vanara.Extensions;
using Vanara.InteropServices;
using static Vanara.PInvoke.Kernel32;
using static Vanara.PInvoke.Macros;
using static Vanara.PInvoke.User32;
using static Vanara.PInvoke.User32_Gdi;
namespace Vanara.PInvoke.Tests
{

View File

@ -130,6 +130,10 @@
<Project>{1f0b972a-06da-4f6a-8b60-87d76fb1f2d9}</Project>
<Name>Vanara.PInvoke.CredUI</Name>
</ProjectReference>
<ProjectReference Include="..\PInvoke\Crypt32\Vanara.PInvoke.Crypt32.csproj">
<Project>{bd86fd1b-d52e-4b78-89ac-36d89458ebd8}</Project>
<Name>Vanara.PInvoke.Crypt32</Name>
</ProjectReference>
<ProjectReference Include="..\PInvoke\DwmApi\Vanara.PInvoke.DwmApi.csproj">
<Project>{e1c6d6af-60a0-42cd-af77-f0de0ffe1395}</Project>
<Name>Vanara.PInvoke.DwmApi</Name>
@ -142,6 +146,10 @@
<Project>{842d436f-598c-47d7-b5aa-12399f8ccfe9}</Project>
<Name>Vanara.PInvoke.Kernel32</Name>
</ProjectReference>
<ProjectReference Include="..\PInvoke\Mpr\Vanara.PInvoke.Mpr.csproj">
<Project>{e91c263f-82d9-40a9-99a1-f879cb076bce}</Project>
<Name>Vanara.PInvoke.Mpr</Name>
</ProjectReference>
<ProjectReference Include="..\PInvoke\NetApi32\Vanara.PInvoke.NetApi32.csproj">
<Project>{48ed1b1b-1450-43d2-917e-b5ace357fd82}</Project>
<Name>Vanara.PInvoke.NetApi32</Name>
@ -178,6 +186,10 @@
<Project>{ac7d45c6-3c00-4fbf-90be-1a026fb26df0}</Project>
<Name>Vanara.PInvoke.TaskSchd</Name>
</ProjectReference>
<ProjectReference Include="..\PInvoke\User32.Gdi\Vanara.PInvoke.User32.Gdi.csproj">
<Project>{fc7b25b5-3bb9-44f5-93d9-9ab7193b1be9}</Project>
<Name>Vanara.PInvoke.User32.Gdi</Name>
</ProjectReference>
<ProjectReference Include="..\PInvoke\User32\Vanara.PInvoke.User32.csproj">
<Project>{a6771907-addc-49fc-8444-a97aa65e77e2}</Project>
<Name>Vanara.PInvoke.User32</Name>
@ -206,6 +218,10 @@
<Project>{51986cd3-eeda-4369-93a4-255512548f68}</Project>
<Name>Vanara.Windows.Forms</Name>
</ProjectReference>
<ProjectReference Include="..\Windows.Shell\Vanara.Windows.Shell.csproj">
<Project>{43685be2-a65e-4b01-be16-479526940f23}</Project>
<Name>Vanara.Windows.Shell</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />