forked from microsoft/WindowsAppSDK
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppInstanceRegisterKeyTests.cpp
More file actions
65 lines (55 loc) · 1.99 KB
/
AppInstanceRegisterKeyTests.cpp
File metadata and controls
65 lines (55 loc) · 1.99 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.
#include "pch.h"
#include <testdef.h>
#include "Shared.h"
using namespace WEX::Common;
using namespace WEX::Logging;
using namespace WEX::TestExecution;
using namespace winrt;
using namespace winrt::Microsoft::Windows::AppLifecycle;
using namespace winrt::Windows::ApplicationModel::Activation;
using namespace winrt::Windows::Foundation;
using namespace winrt::Windows::Foundation::Collections;
using namespace winrt::Windows::Management::Deployment;
using namespace winrt::Windows::Storage;
using namespace winrt::Windows::System;
namespace Test::AppLifecycle
{
class AppInstanceRegisterKeyTests
{
private:
const std::wstring c_testKeyName = L"TestKey_ReRegister";
public:
BEGIN_TEST_CLASS(AppInstanceRegisterKeyTests)
TEST_CLASS_PROPERTY(L"ThreadingModel", L"MTA")
TEST_CLASS_PROPERTY(L"RunAs:Class", L"RestrictedUser")
END_TEST_CLASS()
TEST_CLASS_SETUP(ClassInit)
{
::Test::Bootstrap::Setup();
return true;
}
TEST_CLASS_CLEANUP(ClassUninit)
{
::Test::Bootstrap::Cleanup();
return true;
}
TEST_METHOD(UnregisterAndReRegisterKey)
{
// First register a key
auto instance = AppInstance::FindOrRegisterForKey(c_testKeyName);
VERIFY_IS_NOT_NULL(instance);
VERIFY_IS_TRUE(instance.IsCurrent());
VERIFY_ARE_EQUAL(instance.Key(), c_testKeyName);
// Unregister the key
instance.UnregisterKey();
VERIFY_ARE_EQUAL(instance.Key(), L"");
// Re-register the same key
auto reRegisteredInstance = AppInstance::FindOrRegisterForKey(c_testKeyName);
VERIFY_IS_NOT_NULL(reRegisteredInstance);
VERIFY_IS_TRUE(reRegisteredInstance.IsCurrent());
VERIFY_ARE_EQUAL(reRegisteredInstance.Key(), c_testKeyName);
}
};
}