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
|
#include "testing/testing.hpp"
#include "editor/user_stats.hpp"
#include "platform/platform_tests_support/writable_dir_changer.hpp"
namespace editor
{
namespace
{
auto constexpr kEditorTestDir = "editor-tests";
auto constexpr kUserName = "Vladimir BI";
UNIT_TEST(UserStatsLoader_Smoke)
{
WritableDirChanger wdc(kEditorTestDir, WritableDirChanger::SettingsDirPolicy::UseWritableDir);
{
UserStatsLoader statsLoader;
TEST(!statsLoader.GetStats(kUserName), ());
}
{
// This user made only two changes and the possibility of further changes is very low.
UserStatsLoader statsLoader;
statsLoader.Update(kUserName);
auto const userStats = statsLoader.GetStats(kUserName);
TEST(userStats, ());
int32_t rank, changesCount;
TEST(userStats.GetRank(rank), ());
TEST(userStats.GetChangesCount(changesCount), ());
TEST_GREATER_OR_EQUAL(rank, 5800, ());
TEST_EQUAL(changesCount, 2, ());
}
// This test checks if user stats info was stored in setting.
// NOTE: there Update function is not called.
{
UserStatsLoader statsLoader;
TEST_EQUAL(statsLoader.GetUserName(), kUserName, ());
auto const userStats = statsLoader.GetStats(kUserName);
TEST(userStats, ());
int32_t rank, changesCount;
TEST(userStats.GetRank(rank), ());
TEST(userStats.GetChangesCount(changesCount), ());
TEST_GREATER_OR_EQUAL(rank, 5800, ());
TEST_EQUAL(changesCount, 2, ());
}
}
} // namespace
} // namespace editor
|