Serialization of Derived Class - MS Test Passes 'Debug', Fails 'Run'

J

jehugaleahsa

I have a base class called DataObject:

[Serializable]
public abstract class DataObject
{
/* Methods only */
}

[Serializable]
public class Customer : DataObject, ICustomer
{

}

My tests use MemoryStream and BinaryFormatter to tests the
serialization. Something like this:

using (MemoryStream stream = new MemoryStream())
{
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(stream, customer);
stream.Position = 0;
Customer copy = (Customer) formatter.Deserialize(stream);
}

I am using MS' Team System Tester. When I 'Run' these tests, I get an
error claiming that DataObject is not marked serializable. But, if I
'Debug' these tests, they all pass.

It is almost as if testing tool has a bug in it. Is there a reason my
code would work when I 'Debug' it? I also noticed that after the first
'Debug', subsequent 'Run' pass.

Has anyone else run into this?
 
M

Mr. Arnold

I have a base class called DataObject:

I am using MS' Team System Tester. When I 'Run' these tests, I get an
error claiming that DataObject is not marked serializable. But, if I
'Debug' these tests, they all pass.

It is almost as if testing tool has a bug in it. Is there a reason my
code would work when I 'Debug' it? I also noticed that after the first
'Debug', subsequent 'Run' pass.

Has anyone else run into this?

Maybe you should look into using Rhino Mocks to mock-up the DataObject,
MBUnit Framework and Gallio. Rhino Mocks and Gallio are Open source and
free, and MBUnit Framework comes with .NET.
 
J

jehugaleahsa

I have a base class called DataObject:

[Serializable]
public abstract class DataObject
{
    /* Methods only */

}

[Serializable]
public class Customer : DataObject, ICustomer
{

}

My tests use MemoryStream and BinaryFormatter to tests the
serialization. Something like this:

   using (MemoryStream stream = new MemoryStream())
   {
      BinaryFormatter formatter = new BinaryFormatter();
      formatter.Serialize(stream, customer);
      stream.Position = 0;
      Customer copy = (Customer) formatter.Deserialize(stream);
   }

I am using MS' Team System Tester. When I 'Run' these tests, I get an
error claiming that DataObject is not marked serializable. But, if I
'Debug'  these tests, they all pass.

It is almost as if testing tool has a bug in it. Is there a reason my
code would work when I 'Debug' it? I also noticed that after the first
'Debug', subsequent 'Run' pass.

Has anyone else run into this?

I came in on Friday and started looking into this again. I about
killed myself when I saw my project was compiling in Release mode.

This is still probably a bug in the testing tools, but I doubt they
expected developers to be testing in release mode. I guess I'll give
myself the blame for this one.
 

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