-
Notifications
You must be signed in to change notification settings - Fork 12
/
CollectorTests.cpp
69 lines (51 loc) · 1.82 KB
/
CollectorTests.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
#include "pch.h"
#include "../myoddweb.directorywatcher.win/utils/Collector.h"
#include "../myoddweb.directorywatcher.win/utils/Event.h"
#include "../myoddweb.directorywatcher.win/utils/EventAction.h"
#include "../myoddweb.directorywatcher.win/utils/EventError.h"
using myoddweb::directorywatcher::Collector;
using myoddweb::directorywatcher::Event;
using myoddweb::directorywatcher::EventError;
using myoddweb::directorywatcher::EventAction;
constexpr auto MaxCleanupAgeMilliseconds = 100;
TEST(Collector, EmptyCollectorReturnsNothing) {
// create new one.
Collector c(MaxCleanupAgeMilliseconds);
// empty
std::vector<Event*> events;
c.GetEvents(events);
EXPECT_EQ( 0, events.size() );
}
TEST(Collector, PathIsValidWithTwoBackSlash) {
// create new one.
Collector c(MaxCleanupAgeMilliseconds);
c.Add( EventAction::Added, L"c:\\", L"\\foo\\bar.txt", true, EventError::None);
// get it.
std::vector<Event*> events;
c.GetEvents(events);
EXPECT_EQ(1, events.size() );
EXPECT_TRUE(wcscmp(L"c:\\foo\\bar.txt", events[0]->Name) == 0);
delete events[0];
}
TEST(Collector, PathIsValidWithOneBackSlashOnPath) {
// create new one.
Collector c(MaxCleanupAgeMilliseconds);
c.Add(EventAction::Added, L"c:\\", L"foo\\bar.txt", true, EventError::None);
// get it.
std::vector<Event*> events;
c.GetEvents(events);
EXPECT_EQ(1, events.size() );
EXPECT_TRUE(wcscmp(L"c:\\foo\\bar.txt", events[0]->Name) == 0);
delete events[0];
}
TEST(Collector, PathIsValidWithOneBackSlashOnFileName) {
// create new one.
Collector c(MaxCleanupAgeMilliseconds);
c.Add(EventAction::Added, L"c:", L"\\foo\\bar.txt", true, EventError::None );
// get it.
std::vector<Event*> events;
c.GetEvents(events);
EXPECT_EQ(1, events.size() );
EXPECT_TRUE(wcscmp(L"c:\\foo\\bar.txt", events[0]->Name)==0);
delete events[0];
}