Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions src/ControlzEx.Tests/Native/NativeExtensionTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
namespace ControlzEx.Tests.Native
{
using global::Windows.Win32;
using global::Windows.Win32.UI.WindowsAndMessaging;
using NUnit.Framework;

[TestFixture]
public class NativeExtensionTests
{
[Test]
public void RectConvertedFromWindowPositionIsCorrectSize()
{
const int WIDTH = 800;
const int HEIGHT = 600;
var windowPos1 = new WINDOWPOS
{
x = 0,
y = 0,
cx = WIDTH,
cy = HEIGHT
};
var windowPos2 = new WINDOWPOS
{
x = -500,
y = -500,
cx = WIDTH,
cy = HEIGHT
};
var windowPos3 = new WINDOWPOS
{
x = 5000,
y = 5000,
cx = WIDTH,
cy = HEIGHT
};

var rect1 = windowPos1.ToRECT();
var rect2 = windowPos2.ToRECT();
var rect3 = windowPos3.ToRECT();

Assert.That(rect1.GetWidth(), Is.EqualTo(WIDTH));
Assert.That(rect1.GetHeight(), Is.EqualTo(HEIGHT));
Assert.That(rect2.GetWidth(), Is.EqualTo(WIDTH));
Assert.That(rect2.GetHeight(), Is.EqualTo(HEIGHT));
Assert.That(rect3.GetWidth(), Is.EqualTo(WIDTH));
Assert.That(rect3.GetHeight(), Is.EqualTo(HEIGHT));
}
}
}
4 changes: 2 additions & 2 deletions src/ControlzEx/Native/PInvokeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public static RECT ToRECT(this WINDOWPOS windowpos)
{
left = windowpos.x,
top = windowpos.y,
right = (int)windowpos.cx - windowpos.x,
bottom = (int)windowpos.cy - windowpos.y
right = windowpos.x + windowpos.cx,
bottom = windowpos.y + windowpos.cy
};
}
}
Expand Down