forked from scriptcs/scriptcs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObjectSerializerTests.cs
More file actions
52 lines (44 loc) · 1.38 KB
/
ObjectSerializerTests.cs
File metadata and controls
52 lines (44 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using Xunit;
namespace ScriptCs.Hosting.Tests
{
public class ObjectSerializerTests
{
public class TheSerializeMethod
{
private readonly ObjectSerializer _serializer;
public TheSerializeMethod()
{
_serializer = new ObjectSerializer();
}
[Fact]
public void ShouldSerializeTypeMethods()
{
Assert.DoesNotThrow(() => _serializer.Serialize(typeof(Type).GetMethods()));
}
[Fact]
public void ShouldSerializeDelegates()
{
Assert.DoesNotThrow(() => _serializer.Serialize(new Action(() => { })));
Assert.DoesNotThrow(() => _serializer.Serialize(new Foo
{
Action = () => { },
Func = () => "Hello World"
}));
}
[Fact]
public void ShouldSerializeWithCircularReferences()
{
var foo = new Foo();
foo.Parent = foo;
Assert.DoesNotThrow(() => _serializer.Serialize(foo));
}
private class Foo
{
public Action Action { get; set; }
public Func<string> Func { get; set; }
public Foo Parent { get; set; }
}
}
}
}