selfping_actor_ut.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #include "selfping_actor.h"
  2. #include <library/cpp/testing/unittest/registar.h>
  3. #include <library/cpp/actors/testlib/test_runtime.h>
  4. namespace NActors {
  5. namespace Tests {
  6. THolder<TTestActorRuntimeBase> CreateRuntime() {
  7. auto runtime = MakeHolder<TTestActorRuntimeBase>();
  8. runtime->SetScheduledEventFilter([](auto&&, auto&&, auto&&, auto&&) { return false; });
  9. runtime->Initialize();
  10. return runtime;
  11. }
  12. Y_UNIT_TEST_SUITE(TSelfPingTest) {
  13. Y_UNIT_TEST(Basic)
  14. {
  15. auto runtime = CreateRuntime();
  16. //const TActorId sender = runtime.AllocateEdgeActor();
  17. NMonitoring::TDynamicCounters::TCounterPtr counter(new NMonitoring::TCounterForPtr());
  18. NMonitoring::TDynamicCounters::TCounterPtr counter2(new NMonitoring::TCounterForPtr());
  19. auto actor = CreateSelfPingActor(
  20. TDuration::MilliSeconds(100), // sendInterval (unused in test)
  21. counter, counter2);
  22. UNIT_ASSERT_VALUES_EQUAL(counter->Val(), 0);
  23. UNIT_ASSERT_VALUES_EQUAL(counter2->Val(), 0);
  24. const TActorId actorId = runtime->Register(actor);
  25. Y_UNUSED(actorId);
  26. //runtime.Send(new IEventHandle(actorId, sender, new TEvSelfPing::TEvPing(0.0)));
  27. // TODO check after events are handled
  28. //Sleep(TDuration::Seconds(1));
  29. //UNIT_ASSERT((intmax_t)counter->Val() >= (intmax_t)Delay.MicroSeconds());
  30. }
  31. }
  32. } // namespace Tests
  33. } // namespace NActors