Skip to content

Commit 9fdb4a4

Browse files
committed
Fix test cleanup logic.
1 parent 208fd15 commit 9fdb4a4

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

test/MsgPack.UnitTest/Serialization/RegressionTests.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,20 @@ public void TestIssue70()
7070
[Test]
7171
public void TestIssue73()
7272
{
73-
SerializationContext.ConfigureClassic();
74-
var value =
75-
new Dictionary<string,object> { { "1", new object() }, { "2", new object() } };
76-
var serializer = MessagePackSerializer.Get<Dictionary<string, object>>( new SerializationContext() );
77-
using ( var buffer = new MemoryStream() )
73+
var original = SerializationContext.ConfigureClassic();
74+
try
75+
{
76+
var value =
77+
new Dictionary<string, object> { { "1", new object() }, { "2", new object() } };
78+
var serializer = MessagePackSerializer.Get<Dictionary<string, object>>( new SerializationContext() );
79+
using ( var buffer = new MemoryStream() )
80+
{
81+
Assert.Throws<SerializationException>( () => serializer.Pack( buffer, value ) );
82+
}
83+
}
84+
finally
7885
{
79-
Assert.Throws<SerializationException>( () => serializer.Pack( buffer, value ) );
86+
SerializationContext.Default = original;
8087
}
8188
}
8289
}

0 commit comments

Comments
 (0)