@@ -57,13 +57,11 @@ TEST_CASE( "Charging sessions" ) {
5757
5858 sentOperations.clear ();
5959
60- // initialize Context without any configs
60+ // Initialize Context without any configs and enable mock server
6161 mo_initialize ();
62+ mo_useMockServer ();
6263
63- mo_getContext ()->setTicksCb (custom_timer_cb);
64-
65- LoopbackConnection loopback;
66- mo_getContext ()->setConnection (&loopback);
64+ mo_setTicksCb (custom_timer_cb);
6765
6866 auto ocppVersion = GENERATE (MO_OCPP_V16, MO_OCPP_V201);
6967 mo_setOcppVersion (ocppVersion);
@@ -306,7 +304,7 @@ TEST_CASE( "Charging sessions" ) {
306304
307305 SECTION (" Preboot transactions - tx before BootNotification" ) {
308306
309- loopback. setOnline ( false );
307+ mo_loopback_setOnline ( mo_getContext ()-> getConnection (), false );
310308
311309 mo_setVarConfigBool (mo_getApiContext (), " CustomizationCtrlr" , " PreBootTransactions" , MO_CONFIG_EXT_PREFIX " PreBootTransactions" , true );
312310
@@ -330,7 +328,7 @@ TEST_CASE( "Charging sessions" ) {
330328
331329 mo_setUnixTime (BASE_TIME_UNIX);
332330
333- loopback. setOnline ( true );
331+ mo_loopback_setOnline ( mo_getContext ()-> getConnection (), true );
334332 loop ();
335333
336334 const char *startTimeStr = nullptr ;
@@ -375,7 +373,7 @@ TEST_CASE( "Charging sessions" ) {
375373
376374 mocpp_deinitialize();
377375
378- loopback.setOnline( false);
376+ mo_loopback_setOnline(mo_getContext()->getConnection(), false);
379377 mocpp_initialize(loopback, ChargerCredentials("test-runner1234"));
380378
381379 declareConfiguration<bool>(MO_CONFIG_EXT_PREFIX "PreBootTransactions", true, CONFIGURATION_FN)->setBool(true);
@@ -405,7 +403,7 @@ TEST_CASE( "Charging sessions" ) {
405403 checkProcessed = true;
406404 });
407405
408- loopback.setOnline( true);
406+ mo_loopback_setOnline(mo_getContext()->getConnection(), true);
409407
410408 loop();
411409
@@ -426,7 +424,7 @@ TEST_CASE( "Charging sessions" ) {
426424
427425 mocpp_deinitialize();
428426
429- loopback.setOnline( false);
427+ mo_loopback_setOnline(mo_getContext()->getConnection(), false);
430428 mocpp_initialize(loopback, ChargerCredentials("test-runner1234"));
431429
432430 declareConfiguration<bool>(MO_CONFIG_EXT_PREFIX "PreBootTransactions", true, CONFIGURATION_FN)->setBool(true);
@@ -464,7 +462,7 @@ TEST_CASE( "Charging sessions" ) {
464462 REQUIRE(adjustmentDelay == 1);
465463 });
466464
467- loopback.setOnline( true);
465+ mo_loopback_setOnline(mo_getContext()->getConnection(), true);
468466
469467 loop();
470468
@@ -474,7 +472,7 @@ TEST_CASE( "Charging sessions" ) {
474472 SECTION("Preboot transactions - reject tx if limit exceeded") {
475473 mocpp_deinitialize();
476474
477- loopback.setConnected( false);
475+ mo_loopback_setConnected(mo_getContext()->getConnection(), false);
478476 mocpp_initialize(loopback, ChargerCredentials("test-runner1234"));
479477
480478 declareConfiguration<bool>(MO_CONFIG_EXT_PREFIX "PreBootTransactions", true, CONFIGURATION_FN)->setBool(true);
@@ -541,7 +539,7 @@ TEST_CASE( "Charging sessions" ) {
541539 return createEmptyDocument();
542540 });});
543541
544- loopback.setConnected( true);
542+ mo_loopback_setConnected(mo_getContext()->getConnection(), true);
545543 loop();
546544
547545 REQUIRE( txId_confirm == txId_base + MO_TXRECORD_SIZE );
@@ -550,7 +548,7 @@ TEST_CASE( "Charging sessions" ) {
550548 SECTION("Preboot transactions - charge without tx if limit exceeded") {
551549 mocpp_deinitialize();
552550
553- loopback.setConnected( false);
551+ mo_loopback_setConnected(mo_getContext()->getConnection(), false);
554552 mocpp_initialize(loopback, ChargerCredentials("test-runner1234"));
555553
556554 declareConfiguration<bool>(MO_CONFIG_EXT_PREFIX "PreBootTransactions", true, CONFIGURATION_FN)->setBool(true);
@@ -621,7 +619,7 @@ TEST_CASE( "Charging sessions" ) {
621619 return createEmptyDocument();
622620 });});
623621
624- loopback.setConnected( true);
622+ mo_loopback_setConnected(mo_getContext()->getConnection(), true);
625623 loop();
626624
627625 REQUIRE( txId_confirm == txId_base + MO_TXRECORD_SIZE );
@@ -652,7 +650,7 @@ TEST_CASE( "Charging sessions" ) {
652650 loop();
653651
654652 // start Tx #1 (offline tx)
655- loopback.setConnected( false);
653+ mo_loopback_setConnected(mo_getContext()->getConnection(), false);
656654
657655 MO_DBG_DEBUG("begin tx (%s)", tx1_idTag);
658656 beginTransaction(tx1_idTag);
@@ -726,7 +724,7 @@ TEST_CASE( "Charging sessions" ) {
726724 });});
727725
728726 // get online
729- loopback.setConnected( true);
727+ mo_loopback_setConnected(mo_getContext()->getConnection(), true);
730728 loop();
731729
732730 // start Tx #4
@@ -980,7 +978,7 @@ TEST_CASE( "Charging sessions" ) {
980978 return createEmptyDocument();
981979 });});
982980
983- loopback.setOnline( false);
981+ mo_loopback_setOnline(mo_getContext()->getConnection(), false);
984982
985983 REQUIRE( !ocppPermitsCharge() );
986984
@@ -994,7 +992,7 @@ TEST_CASE( "Charging sessions" ) {
994992
995993 mtime += 10 * 60 * 1000; //jump 10 minutes into future
996994
997- loopback.setOnline( true);
995+ mo_loopback_setOnline(mo_getContext()->getConnection(), true);
998996 loop();
999997
1000998 REQUIRE( !checkProcessedStartTx );
@@ -1024,7 +1022,7 @@ TEST_CASE( "Charging sessions" ) {
10241022 checkProcessedStartTx = false;
10251023 checkProcessedStopTx = false;
10261024
1027- loopback.setOnline( false);
1025+ mo_loopback_setOnline(mo_getContext()->getConnection(), false);
10281026
10291027 REQUIRE( !ocppPermitsCharge() );
10301028
@@ -1036,7 +1034,7 @@ TEST_CASE( "Charging sessions" ) {
10361034 loop();
10371035 REQUIRE( !ocppPermitsCharge() );
10381036
1039- loopback.setOnline( true);
1037+ mo_loopback_setOnline(mo_getContext()->getConnection(), true);
10401038 loop();
10411039
10421040 REQUIRE( !checkProcessedStartTx );
@@ -1054,13 +1052,13 @@ TEST_CASE( "Charging sessions" ) {
10541052 REQUIRE( ocppPermitsCharge() );
10551053 REQUIRE( checkProcessedStartTx );
10561054
1057- loopback.setOnline( false);
1055+ mo_loopback_setOnline(mo_getContext()->getConnection(), false);
10581056
10591057 endTransaction();
10601058 loop();
10611059 mtime += 10 * 60 * 1000; //jump 10 minutes into future
10621060
1063- loopback.setOnline( true);
1061+ mo_loopback_setOnline(mo_getContext()->getConnection(), true);
10641062 loop();
10651063 REQUIRE( !checkProcessedStopTx );
10661064
0 commit comments