Skip to content

Instantly share code, notes, and snippets.

@dtchepak
Created May 9, 2011 12:27
Show Gist options
  • Save dtchepak/962435 to your computer and use it in GitHub Desktop.
Save dtchepak/962435 to your computer and use it in GitHub Desktop.
Serializing and .NET mock frameworks
public interface IRoot { string Data { get; set; } }
[Serializable]
public abstract class Root : IRoot { public abstract string Data { get; set; } }
[Test]
public void FailingTest()
{
var root = CreateMock(); // <-- create a mock with your favourite mocking framework for Root or IRoot
var formatter = new BinaryFormatter();
using (var stream = new MemoryStream())
{
formatter.Serialize(stream, root);
stream.Position = 0;
var newRoot = formatter.Deserialize(stream) as IRoot;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment