serializing test objects

K

kkarre

Hi all,
We decided to clear the test db more frequently and I was asked to serialize
som
test objects to make sure our unit testing continues to work after clearing
the db.

Does anyone have any advice on how to implement this?
I've decided on BinaryFormatter because I want to save private fields and
ReadOnly-
properties as well as Public Read/Write Properties.
The objects are modeled as a hierarchi, maincompany, subcompany etc.
Should I put them all in a collection and serialize it?
If I serialize only the MainCompany, the other(lower) objects doesn't seem
to be saved.

Grateful for any tip!
Best Regards,
kk
 
S

sloan

I don't have a direct answer.

But I have some source code that would make for a good test run in your
situation.

http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!114.entry

I have objects,collections of objects, and collections of objects have have
collections of objects.

You would have to strip the Xml serialize stuff and try binary, but most of
the work would be done.

But it would give you some testing ideas.

The children objects should definately serialize. A friendly reminder that
everything needs to be tagged with the [Serilizable] attribute.

...

Hopefully, someone else can chime in as well. But I thought I'd share what
I have.

...
 
K

kkarre

Thankx, I'll look into it shortly.
Best Regards,
Kristian

sloan said:
I don't have a direct answer.

But I have some source code that would make for a good test run in your
situation.

http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!114.entry

I have objects,collections of objects, and collections of objects have have
collections of objects.

You would have to strip the Xml serialize stuff and try binary, but most of
the work would be done.

But it would give you some testing ideas.

The children objects should definately serialize. A friendly reminder that
everything needs to be tagged with the [Serilizable] attribute.

...

Hopefully, someone else can chime in as well. But I thought I'd share what
I have.

...


kkarre said:
Hi all,
We decided to clear the test db more frequently and I was asked to
serialize
som
test objects to make sure our unit testing continues to work after
clearing
the db.

Does anyone have any advice on how to implement this?
I've decided on BinaryFormatter because I want to save private fields and
ReadOnly-
properties as well as Public Read/Write Properties.
The objects are modeled as a hierarchi, maincompany, subcompany etc.
Should I put them all in a collection and serialize it?
If I serialize only the MainCompany, the other(lower) objects doesn't seem
to be saved.

Grateful for any tip!
Best Regards,
kk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top