mirror of https://github.com/dahall/Vanara.git
Added nullability to unit tests for Imm32, User32, and Usp10
parent
3f5dbc6bb0
commit
70a5838202
|
@ -1199,7 +1199,7 @@ public static partial class User32
|
|||
// nBuff, HKL *lpList );
|
||||
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
|
||||
[PInvokeData("winuser.h", MSDNShortId = "")]
|
||||
public static extern int GetKeyboardLayoutList(int nBuff, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] HKL[] lpList);
|
||||
public static extern int GetKeyboardLayoutList(int nBuff, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] HKL[]? lpList);
|
||||
|
||||
/// <summary>Retrieves the name of the active input locale identifier (formerly called the keyboard layout) for the system.</summary>
|
||||
/// <param name="pwszKLID">
|
||||
|
|
|
@ -42,7 +42,7 @@ public class MSImmTests
|
|||
[Test]
|
||||
public void PlugInDictDictionaryListTest()
|
||||
{
|
||||
var idlist = new ImePlugInDictDictionaryList1041() as IImePlugInDictDictionaryList;
|
||||
var idlist = (IImePlugInDictDictionaryList)new ImePlugInDictDictionaryList1041();
|
||||
Assert.That(() => idlist.GetDictionariesInUse(out var guids, out var dt, out var enc), Throws.Nothing);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,22 +9,13 @@ namespace Vanara.PInvoke.Tests;
|
|||
public partial class User32Tests
|
||||
{
|
||||
[Test()]
|
||||
public void CallNextHookExTest()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void CallNextHookExTest() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void ChildWindowFromPointExTest()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void ChildWindowFromPointExTest() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void DestroyIconTest()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void DestroyIconTest() => throw new NotImplementedException();
|
||||
|
||||
[Test]
|
||||
public void EnumDisplayDevicesTest()
|
||||
|
|
|
@ -44,52 +44,28 @@ public partial class User32Tests
|
|||
}
|
||||
|
||||
[Test()]
|
||||
public void GetWindowLongTest()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void GetWindowLongTest() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void GetWindowLong32Test()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void GetWindowLong32Test() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void GetWindowLongPtrTest()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void GetWindowLongPtrTest() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void LockWorkStationTest()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void LockWorkStationTest() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void RealGetWindowClassTest()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void RealGetWindowClassTest() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void RegisterHotKeyTest()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void RegisterHotKeyTest() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void RegisterWindowMessageTest()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void RegisterWindowMessageTest() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void ScreenToClientTest()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void ScreenToClientTest() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void SendMessageTest()
|
||||
|
@ -150,167 +126,86 @@ public partial class User32Tests
|
|||
TestContext.WriteLine(sb);
|
||||
}
|
||||
|
||||
[Test()]
|
||||
public void SendMessageTest2()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
[Test()]
|
||||
public void SendMessageTest2() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void SendMessageTest3()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void SendMessageTest3() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void SendMessageTest4()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void SendMessageTest4() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void SendMessageTest5()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void SendMessageTest5() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void SetWindowLongTest()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void SetWindowLongTest() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void SetWindowPosTest()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void SetWindowPosTest() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void SetWindowTextTest()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void SetWindowTextTest() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void ShutdownBlockReasonCreateTest()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void ShutdownBlockReasonCreateTest() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void ShutdownBlockReasonDestroyTest()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void ShutdownBlockReasonDestroyTest() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void ShutdownBlockReasonQueryTest()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void ShutdownBlockReasonQueryTest() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void ShutdownBlockReasonQueryTest1()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void ShutdownBlockReasonQueryTest1() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void UnhookWindowsHookExTest()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void UnhookWindowsHookExTest() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void UnregisterHotKeyTest()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void UnregisterHotKeyTest() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void WindowFromPointTest()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void WindowFromPointTest() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void ExitWindowsExTest()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void ExitWindowsExTest() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void DrawTextTest()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void DrawTextTest() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void GetClientRectTest()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void GetClientRectTest() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void GetWindowRectTest()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void GetWindowRectTest() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void InvalidateRectTest()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void InvalidateRectTest() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void MapWindowPointsTest()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void MapWindowPointsTest() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void MapWindowPointsTest1()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void MapWindowPointsTest1() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void MapWindowPointsTest2()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void MapWindowPointsTest2() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void SendMessageTest6()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void SendMessageTest6() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void LoadImageTest()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void LoadImageTest() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void LoadStringTest()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void LoadStringTest() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void LoadStringTest1()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void LoadStringTest1() => throw new NotImplementedException();
|
||||
|
||||
[Test()]
|
||||
public void SetWindowsHookExTest()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void SetWindowsHookExTest() => throw new NotImplementedException();
|
||||
|
||||
[Test]
|
||||
public void SystemParametersInfoGetTest()
|
||||
|
@ -371,35 +266,35 @@ public partial class User32Tests
|
|||
var gmi = X(e, mi, CorrespondingAction.Get);
|
||||
if (gmi is null)
|
||||
continue;
|
||||
var param = new object[] { e, null };
|
||||
var param = new object?[] { e, null };
|
||||
TestContext.Write($"{e}: ");
|
||||
if ((bool)gmi.Invoke(null, param))
|
||||
if ((bool)gmi.Invoke(null, param)!)
|
||||
TestContext.WriteLine($"{param[1]}");
|
||||
else
|
||||
TestContext.Write($"ERROR: {Win32Error.GetLastError()}");
|
||||
|
||||
if (!Enum.TryParse(Enum.GetName(typeof(SPI), e).Replace("SPI_GET", "SPI_SET"), out SPI se) || se == SPI.SPI_SETSHOWSOUNDS)
|
||||
if (!Enum.TryParse(Enum.GetName(typeof(SPI), e)!.Replace("SPI_GET", "SPI_SET"), out SPI se) || se == SPI.SPI_SETSHOWSOUNDS)
|
||||
continue;
|
||||
gmi = X(se, smi, CorrespondingAction.Set);
|
||||
if (gmi is null)
|
||||
continue;
|
||||
var sparam = new object[] { se, param[1], false, false };
|
||||
var sparam = new object?[] { se, param[1], false, false };
|
||||
TestContext.Write($"{se}: ");
|
||||
if ((bool)gmi.Invoke(null, sparam))
|
||||
if ((bool)gmi.Invoke(null, sparam)!)
|
||||
TestContext.WriteLine("Pass");
|
||||
else
|
||||
TestContext.Write($"Fail: {Win32Error.GetLastError()}");
|
||||
}
|
||||
|
||||
static MethodInfo X(SPI e, MethodInfo mi, CorrespondingAction a)
|
||||
static MethodInfo? X(SPI e, MethodInfo mi, CorrespondingAction a)
|
||||
{
|
||||
if (!e.GetType().GetField(e.ToString()).GetCustomAttributes<ObsoleteAttribute>().Any())
|
||||
if (!e.GetType().GetField(e.ToString())!.GetCustomAttributes<ObsoleteAttribute>().Any())
|
||||
{
|
||||
var typeAttrs = CorrespondingTypeAttribute.GetAttrForEnum(e).ToArray();
|
||||
if (typeAttrs.Length > 0 && typeAttrs[0].Action == a)
|
||||
{
|
||||
var genType = typeAttrs[0].TypeRef;
|
||||
if (genType.IsValueType)
|
||||
if (genType!.IsValueType)
|
||||
return mi.MakeGenericMethod(genType);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,10 +10,10 @@ public partial class User32Tests
|
|||
[Test]
|
||||
public void WindowClassCtorTest()
|
||||
{
|
||||
WindowClass wc = null;
|
||||
WindowClass? wc = null;
|
||||
|
||||
Assert.DoesNotThrow(() => wc = new());
|
||||
Assert.AreEqual(wc.wc.hInstance, (HINSTANCE)GetModuleHandle());
|
||||
Assert.AreEqual(wc!.wc.hInstance, (HINSTANCE)GetModuleHandle());
|
||||
Assert.True(wc.Unregister());
|
||||
|
||||
Assert.DoesNotThrow(() => wc = new("MyCustomName"));
|
||||
|
@ -32,13 +32,13 @@ public partial class User32Tests
|
|||
{
|
||||
using BasicMessageWindow wnd = new();
|
||||
|
||||
WindowClass wc3 = null;
|
||||
Assert.NotNull(wc3 = WindowClass.GetNamedInstance(wnd.ClassName, GetModuleHandle()));
|
||||
Assert.AreEqual(wnd.ClassName, wc3.ClassName);
|
||||
WindowClass? wc3 = null;
|
||||
Assert.NotNull(wc3 = WindowClass.GetNamedInstance(wnd!.ClassName!, GetModuleHandle()));
|
||||
Assert.AreEqual(wnd.ClassName, wc3!.ClassName);
|
||||
|
||||
WindowClass wc = null;
|
||||
WindowClass? wc = null;
|
||||
Assert.NotNull(wc = WindowClass.GetInstanceFromWindow(wnd.Handle));
|
||||
Assert.AreEqual(wc.ClassName, wnd.ClassName);
|
||||
Assert.AreEqual(wc!.ClassName, wnd.ClassName);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -67,10 +67,7 @@ public partial class User32Tests
|
|||
}
|
||||
|
||||
[Test]
|
||||
public void WindowRunTest()
|
||||
{
|
||||
VisibleWindow.Run<MyWin>(null, "Hello");
|
||||
}
|
||||
public void WindowRunTest() => VisibleWindow.Run<MyWin>(null, "Hello");
|
||||
|
||||
public class MyWin : VisibleWindow
|
||||
{
|
||||
|
|
|
@ -10,9 +10,11 @@ namespace Vanara.PInvoke.Tests;
|
|||
public class Usp10Tests
|
||||
{
|
||||
private const string str = "Hello, world!\u064A\u064F\u0633\u0627\u0648\u0650\u064A How are you?";
|
||||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
||||
private SafeHDC dc;
|
||||
private SafeHFONT fnt;
|
||||
private SafeSCRIPT_CACHE sc;
|
||||
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void _Setup()
|
||||
|
@ -137,8 +139,8 @@ public class Usp10Tests
|
|||
[Test]
|
||||
public void ScriptGetPropertiesTest()
|
||||
{
|
||||
Assert.That(ScriptGetProperties(out SCRIPT_PROPERTIES[] sp), ResultIs.Successful);
|
||||
sp.WriteValues();
|
||||
Assert.That(ScriptGetProperties(out SCRIPT_PROPERTIES[]? sp), ResultIs.Successful);
|
||||
sp?.WriteValues();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -148,10 +150,10 @@ public class Usp10Tests
|
|||
public void ScriptItemizeTest()
|
||||
{
|
||||
const int max = 50;
|
||||
Assert.That(ScriptGetProperties(out SCRIPT_PROPERTIES[] sp), ResultIs.Successful);
|
||||
Assert.That(ScriptGetProperties(out SCRIPT_PROPERTIES[]? sp), ResultIs.Successful);
|
||||
SCRIPT_ITEM[] pItems = new SCRIPT_ITEM[max];
|
||||
Assert.That(ScriptItemize(str, str.Length, pItems.Length, default, default, pItems, out int cItems), ResultIs.Successful);
|
||||
Assert.That(pItems.Take(cItems).Select(i => i.a.eScript).Select(s => sp[s].fComplex), Has.Some.True);
|
||||
Assert.That(pItems.Take(cItems).Select(i => i.a.eScript).Select(s => sp?[s].fComplex), Has.Some.True);
|
||||
foreach (SCRIPT_ITEM i in pItems.Take(cItems))
|
||||
{
|
||||
i.WriteValues();
|
||||
|
@ -162,7 +164,7 @@ public class Usp10Tests
|
|||
public void ScriptItemizeTest2()
|
||||
{
|
||||
const int max = 50;
|
||||
Assert.That(ScriptGetProperties(out SCRIPT_PROPERTIES[] sp), ResultIs.Successful);
|
||||
Assert.That(ScriptGetProperties(out SCRIPT_PROPERTIES[]? sp), ResultIs.Successful);
|
||||
|
||||
Assert.That(ScriptRecordDigitSubstitution(LCID.LOCALE_CUSTOM_DEFAULT, out SCRIPT_DIGITSUBSTITUTE sub), ResultIs.Successful);
|
||||
sub.WriteValues();
|
||||
|
@ -173,7 +175,7 @@ public class Usp10Tests
|
|||
|
||||
SCRIPT_ITEM[] pItems = new SCRIPT_ITEM[max];
|
||||
Assert.That(ScriptItemize(str, str.Length, pItems.Length, sc, ss, pItems, out int cItems), ResultIs.Successful);
|
||||
Assert.That(pItems.Take(cItems).Select(i => i.a.eScript).Select(s => sp[s].fComplex), Has.Some.True);
|
||||
Assert.That(pItems.Take(cItems).Select(i => i.a.eScript).Select(s => sp?[s].fComplex), Has.Some.True);
|
||||
foreach (SCRIPT_ITEM i in pItems.Take(cItems))
|
||||
{
|
||||
i.WriteValues();
|
||||
|
@ -208,6 +210,6 @@ public class Usp10Tests
|
|||
ssa.WriteValues();
|
||||
Assert.That(ssa.Out(POINT.Empty), ResultIs.Successful);
|
||||
Assert.That(ssa.CPtoX(5, true), Is.GreaterThan(0));
|
||||
Assert.That(ssa.XtoCP(ssa.Size.Value.Width).cp, Is.GreaterThan(30));
|
||||
Assert.That(ssa.XtoCP(ssa.Size!.Value.Width).cp, Is.GreaterThan(30));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue