You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Today I noticed that I am still using a really old version of Delphi Mocks (must be from ~2014 😇), so I decided to update. Alas, one of my tests fails with the current version.
The following test checks whether a log-channel receives one message of type A (siCategoriesChanged) and two messages of type B (siSubjectsChanged). So the same method is called multiple times with different parameters. The old version registered this correctly.
procedure TestLogging.TestNotification;
var
MC: TMock<ILogChannel>;
begin
MC := TMock<ILogChannel>.Create;
try
g_Logger.RegisterChannel(MC);
// MC.Setup.Expect.Once.When.StatusChange([siCategoriesChanged]);
MC.Setup.Expect.Exactly(1).When.StatusChange([siCategoriesChanged]);
MC.Setup.Expect.Exactly(2).When.StatusChange([siSubjectsChanged]);
// Check that the log channel receives one category and two subjects
g_Logger.RegisterCategory('A Category');
g_Logger.RegisterSubject('Ein Subject');
g_Logger.RegisterSubject('Noch Ein Subject');
g_Logger.UnregisterChannel(MC);
Assert.WillNotRaise(
procedure
begin
MC.Verify;
end, EMockVerificationException);
finally
MC.Free;
end;
end;
with the current version of Mocks, wiring up the mock channel like this:
Method raised an exception of type : EMockVerificationException
Method : StatusChange
Expectation [ Once When( [siCategoriesChanged] ) - Was 3 ] was not met.
Expectation [ Exactly 2 Times When( [siSubjectsChanged] ) - Was 3 ] was not met.
EMockException with message '[ILogChannel] already defines Expectation Exactly for method [StatusChange] with args.'
plus a handful of EAccessViolation with message 'Zugriffsverletzung bei Adresse 0078A63B in Modul 'RAC.Logging.UnitTests.exe'. Lesen von Adresse 0000000C' in other tests.
No matter if I wire up the channel with Expect.Once or Expect.Exactly(1), the test passes in the old version of Mocks.
This looks like a regression bug to me.
The text was updated successfully, but these errors were encountered:
Miscounting the function calls with parameters, when wiring up the test with Once and Exactly(2))
was introduced in: d75a6db "Updated SameValue & CompareValue to improve testing.", 10.4.2020.
Error Number 2:
Exception '[ILogChannel] already defines Expectation Exactly for method [StatusChange] with args.' was introduced much earlier.
The oldest version that I can compile out of the box (with RAD Studio 10.3.3) is: 37a4ac3 "Added XE7 Support", 2.9.2014,
which already throws the '[ILogChannel] already defines Expectation Exactly for method [StatusChange] with args.' Exception when using Exactly(1) and Exactly(2). It passes when using Once and Exactly(2).
Edit: I went further back in time and even versions from 2011 throw the ILogChannel ... Exception.
Today I noticed that I am still using a really old version of Delphi Mocks (must be from ~2014 😇), so I decided to update. Alas, one of my tests fails with the current version.
The following test checks whether a log-channel receives one message of type A (siCategoriesChanged) and two messages of type B (siSubjectsChanged). So the same method is called multiple times with different parameters. The old version registered this correctly.
with the current version of Mocks, wiring up the mock channel like this:
results in:
and wiring up the channel like this:
results in:
plus a handful of
EAccessViolation with message 'Zugriffsverletzung bei Adresse 0078A63B in Modul 'RAC.Logging.UnitTests.exe'. Lesen von Adresse 0000000C'
in other tests.No matter if I wire up the channel with Expect.Once or Expect.Exactly(1), the test passes in the old version of Mocks.
This looks like a regression bug to me.
The text was updated successfully, but these errors were encountered: