blob: 2ae85a87b182fe6a62c183d6c05821fc0eb22aef (
plain) (
blame)
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
|
#include <library/cpp/testing/unittest/registar.h>
#include <library/cpp/messagebus/rain_check/test/ut/test.h>
#include <util/system/event.h>
using namespace NRainCheck;
using namespace NActor;
Y_UNIT_TEST_SUITE(Sleep) {
struct TTestTask: public ISimpleTask {
TSimpleEnv* const Env;
TTestSync* const TestSync;
TTestTask(TSimpleEnv* env, TTestSync* testSync)
: Env(env)
, TestSync(testSync)
{
}
TSubtaskCompletion Sleep;
TContinueFunc Start() override {
Env->SleepService.Sleep(&Sleep, TDuration::MilliSeconds(1));
TestSync->CheckAndIncrement(0);
return &TTestTask::Continue;
}
TContinueFunc Continue() {
TestSync->CheckAndIncrement(1);
return nullptr;
}
};
Y_UNIT_TEST(Test) {
TTestSync testSync;
TSimpleEnv env;
TIntrusivePtr<TSimpleTaskRunner> task = env.SpawnTask<TTestTask>(&testSync);
testSync.WaitForAndIncrement(2);
}
}
|