Sorry for the title of the post, don't know how to express it better..
I have an object unit which I save to the filesystem using MemoryStream and BinaryFormatter.
Now I have to run an NUNIT test that checks if both objects car and carloadedFromDisk are equal. This test fails, because it looks like they have different references on the heap.
Is it possible to have the deserialized object carloadedFromDisk to point to the existing reference of object car?
What can I do to make the test pass?
Example:
var car = new Car("Audi");
var unit = new Unit("GoldSmith", car);
unit.save();
var carloadedFromDisk = Car.get(carId); // deserialized
Assert.AreEqual(unit.Car, carloadedFromDisk); // <-- fails
 
    