forked from rsocket/rsocket-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConnectionSetTest.cpp
More file actions
54 lines (42 loc) · 1.4 KB
/
ConnectionSetTest.cpp
File metadata and controls
54 lines (42 loc) · 1.4 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
// Copyright 2004-present Facebook. All Rights Reserved.
#include <gtest/gtest.h>
#include <folly/io/async/EventBase.h>
#include "rsocket/RSocketConnectionEvents.h"
#include "rsocket/RSocketResponder.h"
#include "rsocket/RSocketStats.h"
#include "rsocket/internal/ConnectionSet.h"
#include "rsocket/internal/KeepaliveTimer.h"
#include "rsocket/statemachine/RSocketStateMachine.h"
using namespace rsocket;
using namespace testing;
namespace {
std::shared_ptr<RSocketStateMachine> makeStateMachine(folly::EventBase* evb) {
return std::make_shared<RSocketStateMachine>(
std::make_shared<RSocketResponder>(),
std::make_unique<KeepaliveTimer>(std::chrono::seconds{10}, *evb),
RSocketMode::SERVER,
RSocketStats::noop(),
std::make_shared<RSocketConnectionEvents>(),
nullptr /* resumeManager */,
nullptr /* coldResumeHandler */
);
}
}
TEST(ConnectionSet, ImmediateDtor) {
ConnectionSet set;
}
TEST(ConnectionSet, CloseViaMachine) {
folly::EventBase evb;
auto machine = makeStateMachine(&evb);
auto set = std::make_shared<ConnectionSet>();
set->insert(machine, &evb);
machine->registerSet(set);
machine->close({}, StreamCompletionSignal::CANCEL);
}
TEST(ConnectionSet, CloseViaSetDtor) {
folly::EventBase evb;
auto machine = makeStateMachine(&evb);
auto set = std::make_shared<ConnectionSet>();
set->insert(machine, &evb);
machine->registerSet(set);
}