- changed status to open
Implicit conversion from X to Nullable<X> in mocking setup fails for large records
Issue #404
resolved
Hi Stefan!
The implicit conversion from X to Nullable<X> in a syntax like Mock.Setup.Returns(x).When.MethodReturningNullableX fails in rare case with large records.
For the context: The record was a DTO for the table entries where there were around 30+ fields.
It starts working once for example I remove fields f4-f8 or some other fields (very weird).
uses
Spring,
System.SysUtils,
Spring.Mocking,
Spring.Collections;
type
TRecord = record
Name: string;
f1: string;
f2: SmallInt;
f3: TDateTime;
f4: Boolean;
f5: Boolean;
f6: Boolean;
f7: Boolean;
f8: Boolean;
f9: Nullable<TDateTime>;
f10: Boolean;
f11: Nullable<Integer>;
f12: TDateTime;
f13: Nullable<Integer>;
f14: TDateTime;
f15: Boolean;
f16: TGUID;
f17: Boolean;
f18: Nullable<String>;
f19: Nullable<String>;
f20: Nullable<String>;
f21: Nullable<String>;
f22: Nullable<String>;
f23: Nullable<String>;
f24: Nullable<String>;
f25: Nullable<String>;
f26: Nullable<String>;
f27: Nullable<String>;
f28: Nullable<String>;
f29: Nullable<String>;
f30: String;
f31: String;
f32: Nullable<String>;
f33: Nullable<String>;
f34: Nullable<TGUID>;
end;
IService = interface(IInvokable)
['{C585B00C-AB3F-4414-B3AE-01C34FA8AE16}']
function Find: Nullable<TRecord>;
end;
var
LMock: Mock<IService>;
R: TRecord;
begin
try
R := Default(TRecord);
R.Name := 'Test';
LMock.Setup.Returns(R).When.Find;
var LValue := LMock.Instance.Find;
Writeln(LValue.Value.Name);
finally
Readln;
end;
end.
Kind regards,
ZB
Comments (2)
-
repo owner -
repo owner - changed status to resolved
fixed
#404→ <<cset 5c5ea0c56203>>
- Log in to comment
I see, the defect is not related to mocking but to the conversion of X to Nullable<T> and is caused by using Byte for the HasValueOffset - well obviously when the record is large enough that offset is larger than 255 and causes a wrong result - gonna fix that shortly.