diff --git a/score/mw/com/impl/skeleton_base.cpp b/score/mw/com/impl/skeleton_base.cpp index 0b189b436..f02d6046c 100644 --- a/score/mw/com/impl/skeleton_base.cpp +++ b/score/mw/com/impl/skeleton_base.cpp @@ -21,13 +21,14 @@ #include "score/mw/com/impl/skeleton_field_base.h" #include "score/mw/com/impl/tracing/skeleton_tracing.h" +#include "score/scope_exit/scope_exit.h" + #include "score/mw/log/logging.h" #include #include #include -#include #include #include #include @@ -99,8 +100,9 @@ SkeletonBase::SkeletonBase(std::unique_ptr skeleton_binding, In "Skeleton binding should be checked in SkeletonWrapperClass::Create() before constructing the SkeletonBase."); } -score::Result SkeletonBase::OfferServiceEvents() const noexcept +score::Result>> SkeletonBase::OfferServiceEvents() const noexcept { + std::vector> offer_guards{}; for (const auto& event : events_) { const auto event_name = event.first; @@ -113,12 +115,16 @@ score::Result SkeletonBase::OfferServiceEvents() const noexcept << ": Reason:" << offer_result.error().Message() << ": " << offer_result.error().UserMessage(); return MakeUnexpected(ComErrc::kBindingFailure); } + offer_guards.emplace_back([&skeleton_event]() { + skeleton_event.PrepareStopOffer(); + }); } - return {}; + return {std::move(offer_guards)}; } -score::Result SkeletonBase::OfferServiceFields() const noexcept +score::Result>> SkeletonBase::OfferServiceFields() const noexcept { + std::vector> offer_guards{}; for (const auto& field : fields_) { const auto field_name = field.first; @@ -135,8 +141,11 @@ score::Result SkeletonBase::OfferServiceFields() const noexcept } return MakeUnexpected(ComErrc::kBindingFailure); } + offer_guards.emplace_back([&skeleton_field]() { + skeleton_field.PrepareStopOffer(); + }); } - return {}; + return {std::move(offer_guards)}; } auto SkeletonBase::OfferService() noexcept -> Result @@ -166,21 +175,22 @@ auto SkeletonBase::OfferService() noexcept -> Result << result.error().UserMessage(); return MakeUnexpected(ComErrc::kBindingFailure); } + utils::ScopeExit binding_offer_guard{[this]() { + binding_->PrepareStopOffer({}); + }}; - const auto event_verification_result = OfferServiceEvents(); - if (!event_verification_result.has_value()) + auto event_offer_guards_result = OfferServiceEvents(); + if (!event_offer_guards_result.has_value()) { - return event_verification_result; + return MakeUnexpected(event_offer_guards_result.error()); } - const auto fields_verification_result = OfferServiceFields(); - if (!fields_verification_result.has_value()) + auto field_offer_guards_result = OfferServiceFields(); + if (!field_offer_guards_result.has_value()) { - return fields_verification_result; + return MakeUnexpected(field_offer_guards_result.error()); } - service_offered_flag_.Set(); - const auto service_discovery_offer_result = Runtime::getInstance().GetServiceDiscovery().OfferService(instance_id_); if (!service_discovery_offer_result.has_value()) { @@ -191,6 +201,19 @@ auto SkeletonBase::OfferService() noexcept -> Result return MakeUnexpected(ComErrc::kBindingFailure); } + service_offered_flag_.Set(); + + // Since the service has been successfully offered, we release the offer guards so that they do not call + // PrepareStopOffer() when they go out of scope. + binding_offer_guard.Release(); + auto release_guards = [](auto& offer_guards) { + for (auto& guard : offer_guards) + { + guard.Release(); + } + }; + release_guards(event_offer_guards_result.value()); + release_guards(field_offer_guards_result.value()); return {}; } diff --git a/score/mw/com/impl/skeleton_base.h b/score/mw/com/impl/skeleton_base.h index b14ce2d46..a33dbb141 100644 --- a/score/mw/com/impl/skeleton_base.h +++ b/score/mw/com/impl/skeleton_base.h @@ -23,6 +23,7 @@ #include "score/mw/com/impl/mocking/i_skeleton_base.h" #include "score/result/result.h" +#include "score/scope_exit/scope_exit.h" #include #include @@ -108,8 +109,8 @@ class SkeletonBase ISkeletonBase* skeleton_mock_; - [[nodiscard]] score::Result OfferServiceEvents() const noexcept; - [[nodiscard]] score::Result OfferServiceFields() const noexcept; + [[nodiscard]] score::Result>> OfferServiceEvents() const noexcept; + [[nodiscard]] score::Result>> OfferServiceFields() const noexcept; FlagOwner service_offered_flag_; }; diff --git a/score/mw/com/impl/skeleton_base_test.cpp b/score/mw/com/impl/skeleton_base_test.cpp index 7d9370d5f..da131a75f 100644 --- a/score/mw/com/impl/skeleton_base_test.cpp +++ b/score/mw/com/impl/skeleton_base_test.cpp @@ -51,10 +51,12 @@ using TestSampleType = std::uint8_t; const auto kDummyEventName{"DummyEvent"}; const auto kDummyEventName2{"DummyEvent2"}; const auto kDummyFieldName{"DummyField"}; +const auto kDummyFieldName2{"DummyField2"}; const auto kInstanceSpecifier = InstanceSpecifier::Create(std::string{"abc/abc/TirePressurePort"}).value(); const TestSampleType kInitialFieldValue(10); +const TestSampleType kInitialFieldValue2(11); class MyDummySkeleton final : public SkeletonBase { @@ -66,6 +68,7 @@ class MyDummySkeleton final : public SkeletonBase // Explicity not having WithGetter/Setter tags since Get/Set functionality is tested in skeleton_field_test.cpp.. SkeletonField dummy_field{*this, kDummyFieldName}; + SkeletonField dummy_field2{*this, kDummyFieldName2}; }; mock_binding::Skeleton& GetMockBinding(MyDummySkeleton& skeleton) noexcept @@ -104,11 +107,13 @@ class SkeletonBaseFixture : public ::testing::Test { auto skeleton_event_mock_ptr_1 = std::make_unique>(); auto skeleton_event_mock_ptr_2 = std::make_unique>(); - auto skeleton_field_mock_ptr = std::make_unique>(); + auto skeleton_field_mock_ptr_1 = std::make_unique>(); + auto skeleton_field_mock_ptr_2 = std::make_unique>(); event_binding_mock_1_ = skeleton_event_mock_ptr_1.get(); event_binding_mock_2_ = skeleton_event_mock_ptr_2.get(); - field_binding_mock_ = skeleton_field_mock_ptr.get(); + field_binding_mock_1_ = skeleton_field_mock_ptr_1.get(); + field_binding_mock_2_ = skeleton_field_mock_ptr_2.get(); EXPECT_CALL(skeleton_event_binding_factory_mock_guard_.factory_mock_, Create(instance_identifier, _, kDummyEventName)) @@ -118,11 +123,15 @@ class SkeletonBaseFixture : public ::testing::Test .WillOnce(Return(ByMove(std::move(skeleton_event_mock_ptr_2)))); EXPECT_CALL(skeleton_field_binding_factory_mock_guard_.factory_mock_, CreateEventBinding(instance_identifier, _, kDummyFieldName, _)) - .WillOnce(Return(ByMove(std::move(skeleton_field_mock_ptr)))); + .WillOnce(Return(ByMove(std::move(skeleton_field_mock_ptr_1)))); + EXPECT_CALL(skeleton_field_binding_factory_mock_guard_.factory_mock_, + CreateEventBinding(instance_identifier, _, kDummyFieldName2, _)) + .WillOnce(Return(ByMove(std::move(skeleton_field_mock_ptr_2)))); EXPECT_CALL(*event_binding_mock_1_, GetBindingType()).WillOnce(Return(BindingType::kLoLa)); EXPECT_CALL(*event_binding_mock_2_, GetBindingType()).WillOnce(Return(BindingType::kLoLa)); - EXPECT_CALL(*field_binding_mock_, GetBindingType()).WillOnce(Return(BindingType::kLoLa)); + EXPECT_CALL(*field_binding_mock_1_, GetBindingType()).WillOnce(Return(BindingType::kLoLa)); + EXPECT_CALL(*field_binding_mock_2_, GetBindingType()).WillOnce(Return(BindingType::kLoLa)); } void CreateSkeleton(const InstanceIdentifier& instance_identifier) noexcept @@ -147,7 +156,8 @@ class SkeletonBaseFixture : public ::testing::Test EXPECT_CALL(*binding_mock_, PrepareOffer(_, _, _)); EXPECT_CALL(*event_binding_mock_1_, PrepareOffer()); EXPECT_CALL(*event_binding_mock_2_, PrepareOffer()); - EXPECT_CALL(*field_binding_mock_, PrepareOffer()); + EXPECT_CALL(*field_binding_mock_1_, PrepareOffer()); + EXPECT_CALL(*field_binding_mock_2_, PrepareOffer()); EXPECT_CALL(service_discovery_mock_, OfferService(_)); } @@ -156,7 +166,8 @@ class SkeletonBaseFixture : public ::testing::Test // PrepareStopOffer is called on the skeleton binding and both events EXPECT_CALL(*event_binding_mock_1_, PrepareStopOffer()); EXPECT_CALL(*event_binding_mock_2_, PrepareStopOffer()); - EXPECT_CALL(*field_binding_mock_, PrepareStopOffer()); + EXPECT_CALL(*field_binding_mock_1_, PrepareStopOffer()); + EXPECT_CALL(*field_binding_mock_2_, PrepareStopOffer()); EXPECT_CALL(*binding_mock_, PrepareStopOffer(_)); EXPECT_CALL(service_discovery_mock_, StopOfferService(_)); } @@ -185,7 +196,8 @@ class SkeletonBaseFixture : public ::testing::Test mock_binding::Skeleton* binding_mock_{nullptr}; mock_binding::SkeletonEvent* event_binding_mock_1_{nullptr}; mock_binding::SkeletonEvent* event_binding_mock_2_{nullptr}; - mock_binding::SkeletonEvent* field_binding_mock_{nullptr}; + mock_binding::SkeletonEvent* field_binding_mock_1_{nullptr}; + mock_binding::SkeletonEvent* field_binding_mock_2_{nullptr}; SkeletonEventBindingFactoryMockGuard skeleton_event_binding_factory_mock_guard_{}; SkeletonFieldBindingFactoryMockGuard skeleton_field_binding_factory_mock_guard_{}; @@ -218,11 +230,13 @@ TEST_F(SkeletonBaseOfferFixture, OfferService) // Expecting that PrepareOffer gets called on the skeleton binding and each event ExpectOfferService(); - // and expecting that Send is called on the event binding with the initial value - EXPECT_CALL(*field_binding_mock_, Send(kInitialFieldValue, _, _)); + // and expecting that Send is called on the field event bindings with the initial value + EXPECT_CALL(*field_binding_mock_1_, Send(kInitialFieldValue, _, _)); + EXPECT_CALL(*field_binding_mock_2_, Send(kInitialFieldValue2, _, _)); - // and the initial field value is set + // and the initial field values are set std::ignore = skeleton_->dummy_field.Update(kInitialFieldValue); + std::ignore = skeleton_->dummy_field2.Update(kInitialFieldValue2); // When offering a Service const auto offer_result = skeleton_->OfferService(); @@ -233,7 +247,6 @@ TEST_F(SkeletonBaseOfferFixture, OfferService) TEST_F(SkeletonBaseOfferFixture, OfferServiceFailsIfAllMethodsHaveNotBeenRegistered) { - // Given a constructed Skeleton with a valid identifier with two events and a field registered with the skeleton CreateSkeleton(GetInstanceIdentifierWithValidBinding()); @@ -272,6 +285,26 @@ TEST_F(SkeletonBaseOfferFixture, CallingPrepareOfferWhenSkeletonBindingPrepareOf ASSERT_EQ(offer_result.error(), ComErrc::kBindingFailure); } +TEST_F(SkeletonBaseOfferFixture, PrepareStopOfferIsNotCalledWhenSkeletonBindingPrepareOfferReturnsError) +{ + // Given a constructed Skeleton with a valid identifier + CreateSkeleton(GetInstanceIdentifierWithValidBinding()); + + // Expect that PrepareOffer fails when being called on the binding + EXPECT_CALL(*binding_mock_, PrepareOffer(_, _, _)) + .WillOnce(Return(MakeUnexpected(ComErrc::kInvalidBindingInformation))); + + // Expect that PrepareStopOffer is not called on the any bindings + EXPECT_CALL(*binding_mock_, PrepareStopOffer(_)).Times(0); + EXPECT_CALL(*event_binding_mock_1_, PrepareStopOffer()).Times(0); + EXPECT_CALL(*event_binding_mock_2_, PrepareStopOffer()).Times(0); + EXPECT_CALL(*field_binding_mock_1_, PrepareStopOffer()).Times(0); + EXPECT_CALL(*field_binding_mock_2_, PrepareStopOffer()).Times(0); + + // When offering a Service + score::cpp::ignore = skeleton_->OfferService(); +} + TEST_F(SkeletonBaseOfferFixture, CallingPrepareOfferWhenEventBindingFailsReturnsError) { RecordProperty("Verifies", "SCR-6222081, SCR-21856131, SCR-17434118"); @@ -303,6 +336,25 @@ TEST_F(SkeletonBaseOfferFixture, CallingPrepareOfferWhenEventBindingFailsReturns ASSERT_EQ(offer_result.error(), ComErrc::kBindingFailure); } +TEST_F(SkeletonBaseOfferFixture, + SkeletonAndOfferedEventBindingsBallPrepareStopOfferWhenSkeletonEventBindingPrepareOfferReturnsError) +{ + // Given a constructed Skeleton with a valid identifier + CreateSkeleton(GetInstanceIdentifierWithValidBinding()); + + // Expect that PrepareOffer fails on the second event binding + EXPECT_CALL(*event_binding_mock_2_, PrepareOffer()) + .WillOnce(Return(MakeUnexpected(ComErrc::kInvalidBindingInformation))); + + // Expect that PrepareStopOffer is called on the first event binding and the skeleton binding, but not on the second + EXPECT_CALL(*binding_mock_, PrepareStopOffer(_)); + EXPECT_CALL(*event_binding_mock_1_, PrepareStopOffer()); + EXPECT_CALL(*event_binding_mock_2_, PrepareStopOffer()).Times(0); + + // When offering a Service + score::cpp::ignore = skeleton_->OfferService(); +} + TEST_F(SkeletonBaseOfferFixture, CallingPrepareOfferWhenFieldValueNotSetReturnsError) { RecordProperty("Verifies", "SCR-6222081, SCR-21856131, SCR-17434118"); @@ -326,6 +378,32 @@ TEST_F(SkeletonBaseOfferFixture, CallingPrepareOfferWhenFieldValueNotSetReturnsE ASSERT_EQ(offer_result.error(), ComErrc::kFieldValueIsNotValid); } +TEST_F(SkeletonBaseOfferFixture, + SkeletonAndEventAndOfferedFieldBindingsCallPrepareStopOfferWhenSkeletonFieldBindingPrepareOfferReturnsError) +{ + // Given a constructed Skeleton with a valid identifier + CreateSkeleton(GetInstanceIdentifierWithValidBinding()); + + // Expect that PrepareOffer fails on the second field binding + EXPECT_CALL(*field_binding_mock_2_, PrepareOffer()) + .WillOnce(Return(MakeUnexpected(ComErrc::kInvalidBindingInformation))); + + // Expect that PrepareStopOffer is called on the first field binding, both event bindings and the skeleton binding, + // but not on the second field binding + EXPECT_CALL(*binding_mock_, PrepareStopOffer(_)); + EXPECT_CALL(*event_binding_mock_1_, PrepareStopOffer()); + EXPECT_CALL(*event_binding_mock_2_, PrepareStopOffer()); + EXPECT_CALL(*field_binding_mock_1_, PrepareStopOffer()); + EXPECT_CALL(*field_binding_mock_2_, PrepareStopOffer()).Times(0); + + // and given the initial field values are set + std::ignore = skeleton_->dummy_field.Update(kInitialFieldValue); + std::ignore = skeleton_->dummy_field2.Update(kInitialFieldValue2); + + // When offering a Service + score::cpp::ignore = skeleton_->OfferService(); +} + TEST_F(SkeletonBaseOfferFixture, CallingPrepareOfferWhenFieldBindingFailsReturnsError) { RecordProperty("Verifies", "SCR-6222081, SCR-21856131, SCR-17434118"); @@ -340,11 +418,12 @@ TEST_F(SkeletonBaseOfferFixture, CallingPrepareOfferWhenFieldBindingFailsReturns CreateSkeleton(GetInstanceIdentifierWithValidBinding()); // Expect that PrepareOffer fails when being called on the field binding - EXPECT_CALL(*field_binding_mock_, PrepareOffer()) + EXPECT_CALL(*field_binding_mock_1_, PrepareOffer()) .WillOnce(Return(MakeUnexpected(ComErrc::kInvalidBindingInformation))); - // and the initial field value is set + // and the initial field values are set std::ignore = skeleton_->dummy_field.Update(kInitialFieldValue); + std::ignore = skeleton_->dummy_field2.Update(kInitialFieldValue2); // and when offering a Service const auto offer_result = skeleton_->OfferService(); @@ -354,6 +433,30 @@ TEST_F(SkeletonBaseOfferFixture, CallingPrepareOfferWhenFieldBindingFailsReturns ASSERT_EQ(offer_result.error(), ComErrc::kBindingFailure); } +TEST_F(SkeletonBaseOfferFixture, AllBindingsCallPrepareStopOfferWhenServiceDiscoveryPrepareOfferReturnsError) +{ + // Given a constructed Skeleton with a valid identifier + CreateSkeleton(GetInstanceIdentifierWithValidBinding()); + + // Expect that PrepareOffer fails on the service discovery binding + EXPECT_CALL(service_discovery_mock_, OfferService(_)) + .WillOnce(Return(MakeUnexpected(ComErrc::kInvalidBindingInformation))); + + // Expect that PrepareStopOffer is called on all the bindings + EXPECT_CALL(*binding_mock_, PrepareStopOffer(_)); + EXPECT_CALL(*event_binding_mock_1_, PrepareStopOffer()); + EXPECT_CALL(*event_binding_mock_2_, PrepareStopOffer()); + EXPECT_CALL(*field_binding_mock_1_, PrepareStopOffer()); + EXPECT_CALL(*field_binding_mock_2_, PrepareStopOffer()); + + // and given the initial field values are set + std::ignore = skeleton_->dummy_field.Update(kInitialFieldValue); + std::ignore = skeleton_->dummy_field2.Update(kInitialFieldValue2); + + // When offering a Service + score::cpp::ignore = skeleton_->OfferService(); +} + using SkeletonBaseOfferDeathTest = SkeletonBaseOfferFixture; TEST_F(SkeletonBaseOfferDeathTest, TerminateOnOfferWithNoBinding) { @@ -396,10 +499,11 @@ TEST_F(SkeletonBaseStopOfferFixture, PrepareStopOffer) ExpectStopOfferService(); // and expecting that Send is called on the event binding with the initial value - EXPECT_CALL(*field_binding_mock_, Send(kInitialFieldValue, _, _)); + EXPECT_CALL(*field_binding_mock_1_, Send(kInitialFieldValue, _, _)); - // and the initial field value is set + // and the initial field values are set std::ignore = skeleton_->dummy_field.Update(kInitialFieldValue); + std::ignore = skeleton_->dummy_field2.Update(kInitialFieldValue2); // When offering a Service const auto offer_result = skeleton_->OfferService(); @@ -419,7 +523,7 @@ TEST_F(SkeletonBaseStopOfferFixture, StopOfferIsNotCalledIfServiceWasNotOffered) // Expecting that PrepareStopOffer is not called on any event or field EXPECT_CALL(*event_binding_mock_1_, PrepareStopOffer()).Times(0); EXPECT_CALL(*event_binding_mock_1_, PrepareStopOffer()).Times(0); - EXPECT_CALL(*field_binding_mock_, PrepareStopOffer()).Times(0); + EXPECT_CALL(*field_binding_mock_1_, PrepareStopOffer()).Times(0); // and that the binding does not get un-initialized (PrepareStopOffer() called) EXPECT_CALL(*binding_mock_, PrepareStopOffer(_)).Times(0); @@ -430,6 +534,8 @@ TEST_F(SkeletonBaseStopOfferFixture, StopOfferIsNotCalledIfServiceWasNotOffered) // Or when destroying the skeleton } +TEST_F(SkeletonBaseStopOfferFixture, StopOfferDoesNotDispatchToBindingsIfOfferFailed) {} + using SkeletonBaseMoveFixture = SkeletonBaseFixture; TEST_F(SkeletonBaseOfferFixture, OfferServiceReturnsErrorWhenServiceDiscoveryOfferServiceFails) { @@ -439,8 +545,9 @@ TEST_F(SkeletonBaseOfferFixture, OfferServiceReturnsErrorWhenServiceDiscoveryOff // Expecting that when OfferService is called on the ServiceDiscovery binding an error is returned EXPECT_CALL(service_discovery_mock_, OfferService(_)).WillOnce(Return(MakeUnexpected(ComErrc::kBindingFailure))); - // and the initial field value is set + // and the initial field values are set std::ignore = skeleton_->dummy_field.Update(kInitialFieldValue); + std::ignore = skeleton_->dummy_field2.Update(kInitialFieldValue2); // When offering a Service const auto offer_result = skeleton_->OfferService(); @@ -458,8 +565,9 @@ TEST_F(SkeletonBaseMoveFixture, SelfMovingAssignmentDoesNotCauseIssues) // Expecting that PrepareOffer gets called on the skeleton binding and each event ExpectOfferService(); - // and the initial field value is set + // and the initial field values are set std::ignore = skeleton_->dummy_field.Update(kInitialFieldValue); + std::ignore = skeleton_->dummy_field2.Update(kInitialFieldValue2); // and given that the service was offered score::cpp::ignore = skeleton_->OfferService(); @@ -471,7 +579,8 @@ TEST_F(SkeletonBaseMoveFixture, SelfMovingAssignmentDoesNotCauseIssues) ASSERT_NE(binding_mock_, nullptr); ASSERT_NE(event_binding_mock_1_, nullptr); ASSERT_NE(event_binding_mock_2_, nullptr); - ASSERT_NE(field_binding_mock_, nullptr); + ASSERT_NE(field_binding_mock_1_, nullptr); + ASSERT_NE(field_binding_mock_2_, nullptr); } TEST_F(SkeletonBaseOfferFixture, ServiceCanBeReOfferedAfterMoveConstructingService) @@ -499,14 +608,17 @@ TEST_F(SkeletonBaseOfferFixture, ServiceCanBeReOfferedAfterMoveConstructingServi EXPECT_CALL(binding_mock, PrepareOffer(_, _, _)).Times(2); EXPECT_CALL(*event_binding_mock_1_, PrepareOffer()).Times(2); EXPECT_CALL(*event_binding_mock_2_, PrepareOffer()).Times(2); - EXPECT_CALL(*field_binding_mock_, PrepareOffer()).Times(2); + EXPECT_CALL(*field_binding_mock_1_, PrepareOffer()).Times(2); + EXPECT_CALL(*field_binding_mock_2_, PrepareOffer()).Times(2); EXPECT_CALL(service_discovery_mock_, OfferService(_)).Times(2); // and expecting that Send is called on the event binding once with the initial value - EXPECT_CALL(*field_binding_mock_, Send(kInitialFieldValue, _, _)); + EXPECT_CALL(*field_binding_mock_1_, Send(kInitialFieldValue, _, _)); + EXPECT_CALL(*field_binding_mock_2_, Send(kInitialFieldValue2, _, _)); - // and the initial field value is set + // and the initial field values are set std::ignore = skeleton.dummy_field.Update(kInitialFieldValue); + std::ignore = skeleton.dummy_field2.Update(kInitialFieldValue2); // When offering the Service const auto offer_result = skeleton.OfferService(); @@ -567,7 +679,13 @@ TEST_F(SkeletonBaseOfferFixture, ServiceCanBeReOfferedAfterCallingStopOfferServi event_offer_count++; return {}; })); - EXPECT_CALL(*field_binding_mock_, PrepareOffer()) + EXPECT_CALL(*field_binding_mock_1_, PrepareOffer()) + .Times(2) + .WillRepeatedly(Invoke([&event_offer_count]() -> Result { + event_offer_count++; + return {}; + })); + EXPECT_CALL(*field_binding_mock_2_, PrepareOffer()) .Times(2) .WillRepeatedly(Invoke([&event_offer_count]() -> Result { event_offer_count++; @@ -576,10 +694,11 @@ TEST_F(SkeletonBaseOfferFixture, ServiceCanBeReOfferedAfterCallingStopOfferServi EXPECT_CALL(service_discovery_mock_, OfferService(_)).Times(2); // and expecting that Send is called on the event binding with the initial value - EXPECT_CALL(*field_binding_mock_, Send(kInitialFieldValue, _, _)); + EXPECT_CALL(*field_binding_mock_1_, Send(kInitialFieldValue, _, _)); - // and the initial field value is set + // and the initial field values are set std::ignore = skeleton.dummy_field.Update(kInitialFieldValue); + std::ignore = skeleton.dummy_field2.Update(kInitialFieldValue2); // When offering the Service const auto offer_result = skeleton.OfferService(); @@ -589,7 +708,7 @@ TEST_F(SkeletonBaseOfferFixture, ServiceCanBeReOfferedAfterCallingStopOfferServi // Then PrepareOffer() is called on the skeleton and events the first time EXPECT_EQ(skeleton_offer_count, 1); - EXPECT_EQ(event_offer_count, 3); + EXPECT_EQ(event_offer_count, 4); // When stop offering a Service skeleton.StopOfferService(); @@ -602,7 +721,7 @@ TEST_F(SkeletonBaseOfferFixture, ServiceCanBeReOfferedAfterCallingStopOfferServi // Then PrepareOffer() is called on the skeleton and events the second time EXPECT_EQ(skeleton_offer_count, 2); - EXPECT_EQ(event_offer_count, 6); + EXPECT_EQ(event_offer_count, 8); // and when the skeleton is destroyed }