- attached DelphiOOP.pdf
Retrieve an entity with a stream
Issue #197
closed
I tried working with Lazy <Stream> to save the pdf file, but I got an error. To simulate ...
TestEntities
...
var
PictureFilename, ScannerFileName, OutputDir: string;
ORMTests
...
begin
OutputDir := IncludeTrailingPathDelimiter(ExtractFileDir(ParamStr(0)));
PictureFilename := IncludeTrailingPathDelimiter(ExpandFileName(OutputDir + '..\..')) + 'DelphiOOP.png';
ScannerFileName := IncludeTrailingPathDelimiter(ExpandFileName(OutputDir + '..\..')) + 'DelphiOOP.pdf';
...
TestSession
I wrote the test...
procedure TSessionTest.GetLazyStream;
var
LCustomer: TCustomer;
stream: TMemoryStream;
begin
stream := TMemoryStream.Create;
try
stream.LoadFromFile(ScannerFileName);
LCustomer := FSession.SingleOrDefault<TCustomer>(SQL_GET_ALL_CUSTOMERS, []);
CheckFalse(Assigned(LCustomer));
InsertCustomerStream(25, 'Stream Lazy', 2.36, 'Middle', stream);
LCustomer := FSession.SingleOrDefault<TCustomer>(SQL_GET_ALL_CUSTOMERS, []);
try
CheckNotNull(LCustomer.CustStream, 'Lazy should have value');
CheckTrue(LCustomer.CustStream.Size > 0, 'Size should be more than 0');
CheckEquals(stream.Size, LCustomer.CustStream.Size, 'file"s size not equals.');
finally
LCustomer.Free;
end;
finally
stream.Free;
end;
end;
The test fails, but if comment value.free at TAbstractSession.MapAggregatedObject ...
function TAbstractSession.MapAggregatedObject(const resultSet: IDBResultSet;
const baseEntity: TObject; entityClass: TClass): TObject;
...
value := Convert(fieldValue);
try
if value.TryConvert(entityClass.ClassInfo, convertedValue) then
Result := convertedValue.AsObject;
finally
// value.Free;
end;
...
The test pass.
I'm using D10Seattle, sorry if it's a mistake.
Comments (8)
-
reporter -
reporter - edited description
-
reporter - marked as minor
- edited description
-
reporter - edited description
-
repo owner - changed status to resolved
fixed issue
#197→ <<cset 2aaf9cff6a56>>
-
repo owner fixed issue
#197→ <<cset 2cf1680161d9>>
-
repo owner fixed issue
#197→ <<cset a13470c81715>>
-
reporter - changed status to closed
This was duly settled and attested.
- Log in to comment