-
Notifications
You must be signed in to change notification settings - Fork 0
/
ClientDeviceContext.Test.cpp
51 lines (47 loc) · 1.08 KB
/
ClientDeviceContext.Test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "WindowsInclude.h"
#include "ClientDeviceContext.h"
#include "Exception.h"
#include <UnitTest/UnitTest.h>
using UnitTest::Assert;
namespace Wex
{
TEST_CLASS(ClientDeviceContextTest)
{
public:
ClientDeviceContextTest()
{
}
TEST_METHOD(WindowConstructor_ValidWithDestructor)
{
const auto window = reinterpret_cast<HWND>(1);
const auto dc = reinterpret_cast<HDC>(2);
API_MOCK(::GetDC) mockGet([=](HWND h)
{
Assert.AreEqual(window, h);
return dc;
});
API_MOCK(::ReleaseDC) mockRelease([=](HWND h, HDC d)
{
Assert.AreEqual(window, h);
Assert.AreEqual(dc, d);
return 0;
});
ClientDeviceContext deviceContext{ window };
Assert.AreEqual(window, deviceContext.window);
Assert.AreEqual(dc, deviceContext.dc);
}
TEST_METHOD(WindowConstructor_Exception)
{
API_MOCK(::GetDC) mock([](HWND)
{
return static_cast<HDC>(nullptr);
});
Assert.ThrowsType<Exception>(
[]{ ClientDeviceContext{ nullptr }; },
[](const Exception& exception)
{
Assert.AreEqual("GetDC", exception.GetLocation());
});
}
};
}