Created
May 9, 2011 12:27
-
-
Save dtchepak/962435 to your computer and use it in GitHub Desktop.
Serializing and .NET mock frameworks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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