-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathClockSkewManagerTests.cpp
72 lines (62 loc) · 2.32 KB
/
ClockSkewManagerTests.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
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
//
#include "common/Common.hpp"
#include "offline/ClockSkewManager.hpp"
using namespace Microsoft::Applications::Events;
TEST(ClockSkewManagerTests, handleResponse_NoTimeDelta_SetsResumeTransmissionAfterClockSkew)
{
ClockSkewManager clockSkewManager;
clockSkewManager.handleResponse(HttpHeaders {});
ASSERT_TRUE(clockSkewManager.GetResumeTransmissionAfterClockSkew());
}
TEST(ClockSkewManagerTests, handleResponse_TimeDeltaSet_SetsResumeTransmissionAfterClockSkew)
{
ClockSkewManager clockSkewManager;
HttpHeaders headers;
headers.add("time-delta-millis", "42");
clockSkewManager.handleResponse(headers);
ASSERT_TRUE(clockSkewManager.GetResumeTransmissionAfterClockSkew());
}
TEST(ClockSkewManagerTests, handleResponse_TimeDeltaEmpty_GetDeltaReturnsSentinel)
{
ClockSkewManager clockSkewManager;
HttpHeaders headers;
headers.add("time-delta-millis", std::string {});
clockSkewManager.handleResponse(headers);
ASSERT_EQ(clockSkewManager.GetDelta(), std::string { "use-collector-delta" });
}
TEST(ClockSkewManagerTests, setDelta_EmptyString_GetDeltaReturnsSentinel)
{
ClockSkewManager clockSkewManager;
clockSkewManager.SetDelta(std::string {});
ASSERT_EQ(clockSkewManager.GetDelta(), std::string { "use-collector-delta" });
}
TEST(ClockSkewManagerTests, isClockSkewOn_DefaultConstructed_ReturnsTrue)
{
ASSERT_TRUE(ClockSkewManager { }.isClockSkewOn());
}
TEST(ClockSkewManagerTests, isClockSkewOn_AfterCallingGetDelta_ReturnsFalse)
{
ClockSkewManager clockSkewManager;
clockSkewManager.GetDelta();
ASSERT_FALSE(clockSkewManager.isClockSkewOn());
}
TEST(ClockSkewManagerTests, isClockSkewOn_AfterCallingSetDeltaNonEmpty_ReturnsTrue)
{
ClockSkewManager clockSkewManager;
clockSkewManager.SetDelta(std::string { "42" });
ASSERT_TRUE(clockSkewManager.isClockSkewOn());
}
TEST(ClockSkewManagerTests, isClockSkewOn_AfterCallingSetDeltaAndGetDeltaEmptyString_ReturnsFalse)
{
ClockSkewManager clockSkewManager;
clockSkewManager.GetDelta();
clockSkewManager.SetDelta(std::string {});
ASSERT_FALSE(clockSkewManager.isClockSkewOn());
}
TEST(ClockSkewManagerTests, GetDelta_DefaultConstructed_ReturnsSentinel)
{
ASSERT_EQ(ClockSkewManager {}.GetDelta(), std::string { "use-collector-delta" });
}