aboutsummaryrefslogblamecommitdiffstats
path: root/library/cpp/messagebus/scheduler/scheduler_ut.cpp
blob: a5ea641c108e7f6bb92f2b64bf6a1634e41e1c1e (plain) (tree)
1
2
3
4
5
6
7
8
9
                                                  

                      
                                                  


                               
                                    




                                                                           
         
 
                            


                                             
                         









                                                               
#include <library/cpp/testing/unittest/registar.h>

#include "scheduler.h"

#include <library/cpp/messagebus/misc/test_sync.h>

using namespace NBus;
using namespace NBus::NPrivate;

Y_UNIT_TEST_SUITE(TSchedulerTests) {
    struct TSimpleScheduleItem: public IScheduleItem {
        TTestSync* const TestSync;

        TSimpleScheduleItem(TTestSync* testSync)
            : IScheduleItem((TInstant::Now() + TDuration::MilliSeconds(1)))
            , TestSync(testSync)
        {
        }

        void Do() override {
            TestSync->WaitForAndIncrement(0);
        }
    };

    Y_UNIT_TEST(Simple) {
        TTestSync testSync;

        TScheduler scheduler;

        scheduler.Schedule(new TSimpleScheduleItem(&testSync));

        testSync.WaitForAndIncrement(1);

        scheduler.Stop();
    }
}