Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #80 from fabriciocolombo/bug-fixes
Fix some bugs and failed tests related to DUnitX migration.
  • Loading branch information
staticcat committed Nov 15, 2015
2 parents 6f9f18c + 6dc37dc commit 6fe0b33
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Delphi.Mocks.MethodData.pas
Expand Up @@ -283,7 +283,7 @@ procedure TMethodData.MockNoBehaviourRecordHit(const Args: TArray<TValue>; const
result := TValue.From<IProxy>(mock);

//Add a behaviour to return the value next time.
behavior := TBehavior.CreateWillReturnWhen(Args, Result, []);
behavior := TBehavior.CreateWillReturnWhen(Args, Result, TArray<IMatcher>.Create());
FBehaviors.Add(behavior);
end
else
Expand Down
2 changes: 2 additions & 0 deletions Delphi.Mocks.Proxy.pas
Expand Up @@ -622,6 +622,8 @@ procedure TProxy<T>.Once(const AMethodName: string);
methodData : IMethodData;
pInfo : PTypeInfo;
begin
pInfo := TypeInfo(T);

methodData := GetMethodData(AMethodName,pInfo.NameStr);
Assert(methodData <> nil);
methodData.Once;
Expand Down
2 changes: 1 addition & 1 deletion Tests/Delphi.Mocks.Tests.MethodData.pas
Expand Up @@ -81,7 +81,7 @@ procedure TTestMethodData.AllowRedefineBehaviorDefinitions_IsFalse_ExceptionIsTh
Assert.WillRaise(procedure
begin
methodData.WillReturnWhen(TArray<TValue>.Create(someValue1), someValue2, nil);
end, EMockException);
end, EMockSetupException);
end;

procedure TTestMethodData.AllowRedefineBehaviorDefinitions_IsFalse_NoExceptionIsThrown_WhenAddingNormal;
Expand Down
10 changes: 5 additions & 5 deletions Tests/Delphi.Mocks.Tests.Utils.pas
Expand Up @@ -62,7 +62,7 @@ procedure TTestTValue.Test_TValue_Equals_SameGuid_Instance;
s2 := s1;
v1 := TValue.From<TGUID>( s1 );
v2 := TValue.From<TGUID>( s2 );
CheckTrue(v1.Equals(v2));
Assert.IsTrue(v1.Equals(v2));
end;

procedure TTestTValue.Test_TValue_Equals_DifferentGuid_Instance;
Expand All @@ -74,7 +74,7 @@ procedure TTestTValue.Test_TValue_Equals_DifferentGuid_Instance;
s2 := StringToGUID( '{2933052C-79D0-48C9-86D3-8FF29416033C}' );
v1 := TValue.From<TGUID>( s1 );
v2 := TValue.From<TGUID>( s2 );
CheckTrue(v1.Equals(v2));
Assert.IsTrue(v1.Equals(v2));
end;

procedure TTestTValue.Test_TValue_NotEquals_Guid;
Expand All @@ -86,7 +86,7 @@ procedure TTestTValue.Test_TValue_NotEquals_Guid;
s2 := StringToGUID( '{2933052C-79D0-48C9-86D3-8FF29416FFFF}' );
v1 := TValue.From<TGUID>( s1 );
v2 := TValue.From<TGUID>( s2 );
CheckFalse(v1.Equals(v2));
Assert.IsFalse(v1.Equals(v2));
end;

procedure TTestTValue.Test_TValue_NotEquals_Interfaces;
Expand All @@ -98,7 +98,7 @@ procedure TTestTValue.Test_TValue_NotEquals_Interfaces;
i2 := TInterfacedObject.Create;
v1 := TValue.From<IInterface>(i1);
v2 := TValue.From<IInterface>(i2);
Assert.IsTrue(v1.Equals(v2));
Assert.IsFalse(v1.Equals(v2));
end;

procedure TTestTValue.Test_TValue_NotEquals_Strings;
Expand All @@ -110,7 +110,7 @@ procedure TTestTValue.Test_TValue_NotEquals_Strings;
s2 := 'goodbye';
v1 := s1;
v2 := s2;
Assert.IsTrue(v1.Equals(v2));
Assert.IsFalse(v1.Equals(v2));
end;

initialization
Expand Down

0 comments on commit 6fe0b33

Please sign in to comment.