Hi,
I am writing test case that uses following strategy:
-=-=-
| memory file |
memory := FileSystem memory.
file := memory workingDirectory / 'file.fuel'.
FLSerializer serialize: {1. 2. 3} toFileNamed: file.
-=-=-
But it does not work because in StandardFileStream class>> #forceNewFileNamed:
a "self fullName: fileName.” is called and it returns a string. So it tries to
create the file in the default real file system; not in the memory file system.
FLSerializer calls it in:
-=-=-
serialize: anObject toFileNamed: aFilename
"Serialize the graph starting at the root object received and answers
the FLSerialization object"
StandardFileStream
forceNewFileNamed: aFilename
do: [ :aFileStream |
aFileStream binary.
self serialize: anObject on: aFileStream ]
-=-=-
using a stream neither work:
-=-=-
| disk file |
disk := FileSystem memory.
file := disk workingDirectory / 'file.fuel'.
file writeStreamDo: [ :aStream |
FLSerializer serialize: {1. 2. 3} on: aStream ].
-=-=-
It produces an improper indexable object.
The only code that works is that one:
-=-=-
| file |
file := FileLocator workingDirectory / 'file.fuel'.
FLSerializer serialize: {1. 2. 3} toFileNamed: file.
-=-=-
I think that using MemoryStore is a clean way to test code that stores contents
into a file.
How can I use FLSerializer and MemoryStore together?
Thanks!
Juraj