Last active
August 29, 2015 13:56
-
-
Save adamjasinski/8861215 to your computer and use it in GitHub Desktop.
This file contains 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 static class ExceptionsFacts | |
{ | |
[Theory, AutoData] | |
static void AllExceptionsShouldBeSerializable( SerializableAssertion assertion ) | |
{ | |
assertion.Verify( typeof( MyException ).Assembly.GetTypes() | |
.Where( x => typeof( Exception ).IsAssignableFrom( x ) ) ); | |
} | |
} | |
class SerializableAssertion : IdiomaticAssertion | |
{ | |
readonly ISpecimenContext _specimenResolver; | |
public SerializableAssertion( ISpecimenBuilder builder ) | |
{ | |
_specimenResolver = new SpecimenContext(builder); | |
} | |
public override void Verify( Type type ) | |
{ | |
var specimen = _specimenResolver.Resolve( type ); | |
//Assert.IsType( type, specimen ); | |
using ( var ms = new MemoryStream() ) | |
new BinaryFormatter().Serialize( ms, specimen ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment