@@ -70,7 +70,7 @@ TMethodData = class(TInterfacedObject,IMethodData)
7070 function FindBehavior (const behaviorType : TBehaviorType; const Args: TArray<TValue>) : IBehavior; overload;
7171 function FindBehavior (const behaviorType : TBehaviorType) : IBehavior; overload;
7272 function FindBestBehavior (const Args: TArray<TValue>) : IBehavior;
73- procedure RecordHit (const Args: TArray<TValue>; const returnType : TRttiType; out Result : TValue);
73+ procedure RecordHit (const Args: TArray<TValue>; const returnType : TRttiType; const method : TRttiMethod; out Result : TValue);
7474
7575 // Expectations
7676 function FindExpectation (const expectationType : TExpectationType; const Args: TArray<TValue>) : IExpectation;overload;
@@ -96,6 +96,8 @@ TMethodData = class(TInterfacedObject,IMethodData)
9696 procedure After (const AAfterMethodName : string);
9797
9898 function Verify (var report : string) : boolean;
99+
100+ function BehaviorDefined : Boolean;
99101 public
100102 constructor Create(const ATypeName : string; const AMethodName : string; const ASetupParameters: TSetupMethodDataParameters; const AAutoMocker : IAutoMock = nil );
101103 destructor Destroy;override;
@@ -111,7 +113,7 @@ implementation
111113 System.TypInfo,
112114 Delphi.Mocks.Utils,
113115 Delphi.Mocks.Behavior,
114- Delphi.Mocks.Expectation;
116+ Delphi.Mocks.Expectation, Delphi.Mocks.Helpers ;
115117
116118
117119
@@ -263,6 +265,11 @@ function TMethodData.FindExpectation(const expectationTypes : TExpectationTypes)
263265 end ;
264266end ;
265267
268+ function TMethodData.BehaviorDefined : Boolean;
269+ begin
270+ Result := (FBehaviors.Count <> 0 );
271+ end ;
272+
266273procedure TMethodData.MockNoBehaviourRecordHit (const Args: TArray<TValue>; const AExpectationHitCtr : Integer; const returnType: TRttiType; out Result: TValue);
267274var
268275 behavior : IBehavior;
@@ -499,7 +506,7 @@ procedure TMethodData.OnceWhen(const Args: TArray<TValue>; const matchers : TArr
499506end ;
500507
501508
502- procedure TMethodData.RecordHit (const Args: TArray<TValue>; const returnType : TRttiType; out Result: TValue);
509+ procedure TMethodData.RecordHit (const Args: TArray<TValue>; const returnType : TRttiType; const method : TRttiMethod; out Result: TValue);
503510var
504511 behavior : IBehavior;
505512 expectation : IExpectation;
@@ -519,17 +526,16 @@ procedure TMethodData.RecordHit(const Args: TArray<TValue>; const returnType : T
519526 behavior := FindBestBehavior(Args);
520527 if behavior <> nil then
521528 returnValue := behavior.Execute(Args, returnType)
522- else
523- begin
529+ else begin
524530 if FSetupParameters.IsStub then
525531 StubNoBehaviourRecordHit(Args, expectationHitCtr, returnType, returnValue)
526532 else
527- MockNoBehaviourRecordHit(Args, expectationHitCtr, returnType, returnValue);
533+ if method.IsAbstract then
534+ MockNoBehaviourRecordHit(Args, expectationHitCtr, returnType, returnValue);
528535 end ;
529536
530537 if returnType <> nil then
531538 Result := returnValue;
532-
533539end ;
534540
535541procedure TMethodData.StubNoBehaviourRecordHit (const Args: TArray<TValue>; const AExpectationHitCtr : Integer; const returnType: TRttiType; out Result: TValue);
0 commit comments