File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
ICSharpCode.AvalonEdit.Tests Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ using ICSharpCode . AvalonEdit . Document ;
2
+ using ICSharpCode . AvalonEdit . Highlighting ;
3
+ using Newtonsoft . Json ;
4
+ using NUnit . Framework ;
5
+
6
+
7
+ namespace ICSharpCode . AvalonEdit . Tests . Highlighting
8
+ {
9
+ [ TestFixture ]
10
+ public class DeserializationTests
11
+ {
12
+ TextDocument document ;
13
+ DocumentHighlighter highlighter ;
14
+
15
+ [ SetUp ]
16
+ public void SetUp ( )
17
+ {
18
+ document = new TextDocument ( "using System.Text;\n \t string text = SomeMethod();" ) ;
19
+ highlighter = new DocumentHighlighter ( document , HighlightingManager . Instance . GetDefinition ( "C#" ) ) ;
20
+ }
21
+
22
+ [ Test ]
23
+ public void TestRoundTripColor ( )
24
+ {
25
+ HighlightingColor color = highlighter . GetNamedColor ( "Comment" ) ;
26
+ string jsonString = JsonConvert . SerializeObject ( color ) ;
27
+
28
+ HighlightingColor color2 = JsonConvert . DeserializeObject < HighlightingColor > ( jsonString ) ;
29
+ Assert . AreEqual ( color , color2 ) ;
30
+ }
31
+ }
32
+ }
Original file line number Diff line number Diff line change 22
22
<DefineConstants >TRACE</DefineConstants >
23
23
</PropertyGroup >
24
24
<ItemGroup >
25
+ <PackageReference Include =" Newtonsoft.Json" Version =" 12.0.3" />
25
26
<PackageReference Include =" NUnit" Version =" 3.11.0" />
26
27
<PackageReference Include =" NUnit3TestAdapter" Version =" 3.13.0" />
27
28
</ItemGroup >
You can’t perform that action at this time.
0 commit comments