-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathTransmitProfileRuleTests.cpp
93 lines (81 loc) · 3.16 KB
/
TransmitProfileRuleTests.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
//
#include "common/Common.hpp"
#include <TransmitProfiles.hpp>
using namespace testing;
using namespace MAT;
TEST(TransmitProfileRuleTests, DefaultConstructor_NetworkCostIsAny)
{
TransmitProfileRule rule;
ASSERT_EQ(rule.netCost, NetworkCost_Any);
}
TEST(TransmitProfileRuleTests, DefaultConstructor_PowerStateIsAny)
{
TransmitProfileRule rule;
ASSERT_EQ(rule.powerState, PowerSource_Any);
}
TEST(TransmitProfileRuleTests, DefaultConstructor_NetworkTypeIsAny)
{
TransmitProfileRule rule;
ASSERT_EQ(rule.netType, NetworkType_Any);
}
TEST(TransmitProfileRuleTests, DefaultConstructor_NetworkSpeedIsZero)
{
TransmitProfileRule rule;
ASSERT_EQ(rule.netSpeed, unsigned{0});
}
TEST(TransmitProfileRuleTests, DefaultConstructor_TimersSizeIsZero)
{
TransmitProfileRule rule;
ASSERT_EQ(rule.timers.size(), size_t{0});
}
TEST(TransmitProfileRuleTests, TimerConstructor_TimersSizeThree_TimersSet)
{
TransmitProfileRule rule{{1, 2, 3}};
ASSERT_EQ(rule.timers.size(), size_t{3});
ASSERT_EQ(rule.timers[0], 1);
ASSERT_EQ(rule.timers[1], 2);
ASSERT_EQ(rule.timers[2], 3);
}
TEST(TransmitProfileRuleTests, TimerConstructor_TimersSizeThree_OtherValuesUnmodified)
{
TransmitProfileRule rule{{1, 2, 3}};
ASSERT_EQ(rule.netCost, NetworkCost::NetworkCost_Any);
ASSERT_EQ(rule.powerState, PowerSource::PowerSource_Any);
ASSERT_EQ(rule.netType, NetworkType::NetworkType_Any);
ASSERT_EQ(rule.netSpeed, unsigned{0});
}
TEST(TransmitProfileRuleTests, NetCostAndTimerConstructor_NetCostLowTimersSizeThree_NetCostAndTimersSet)
{
TransmitProfileRule rule{NetworkCost::NetworkCost_Unmetered, {1, 2, 3}};
ASSERT_EQ(rule.netCost, NetworkCost::NetworkCost_Unmetered);
ASSERT_EQ(rule.timers.size(), size_t{3});
ASSERT_EQ(rule.timers[0], 1);
ASSERT_EQ(rule.timers[1], 2);
ASSERT_EQ(rule.timers[2], 3);
}
TEST(TransmitProfileRuleTests, NetCostAndTimerConstructor_NetCostLowTimersSizeThree_OtherValuesUnmodified)
{
TransmitProfileRule rule{NetworkCost::NetworkCost_Unmetered, {1, 2, 3}};
ASSERT_EQ(rule.powerState, PowerSource::PowerSource_Any);
ASSERT_EQ(rule.netType, NetworkType::NetworkType_Any);
ASSERT_EQ(rule.netSpeed, unsigned{0});
}
TEST(TransmitProfileRuleTests, NetCostPowerSourceAndTimerConstructor_NetCostLowPowerSourceBatteryTimersSizeThree_NetCostPowerSourceAndTimersSet)
{
TransmitProfileRule rule{NetworkCost::NetworkCost_Unmetered, PowerSource::PowerSource_Battery, {1, 2, 3}};
ASSERT_EQ(rule.netCost, NetworkCost::NetworkCost_Unmetered);
ASSERT_EQ(rule.powerState, PowerSource::PowerSource_Battery);
ASSERT_EQ(rule.timers.size(), size_t{3});
ASSERT_EQ(rule.timers[0], 1);
ASSERT_EQ(rule.timers[1], 2);
ASSERT_EQ(rule.timers[2], 3);
}
TEST(TransmitProfileRuleTests, NetCostPowerSourceAndTimerConstructor_NetCostLowPowerSourceBatteryTimersSizeThree_OtherValuesUnmodified)
{
TransmitProfileRule rule{NetworkCost::NetworkCost_Unmetered, PowerSource::PowerSource_Battery, {1, 2, 3}};
ASSERT_EQ(rule.netType, NetworkType::NetworkType_Any);
ASSERT_EQ(rule.netSpeed, unsigned{0});
}