Skip to content

Commit f57441b

Browse files
committed
Add NewtonSoft.Json and red round-tip test
1 parent 9ecaeb0 commit f57441b

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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\tstring 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+
}

ICSharpCode.AvalonEdit.Tests/ICSharpCode.AvalonEdit.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<DefineConstants>TRACE</DefineConstants>
2323
</PropertyGroup>
2424
<ItemGroup>
25+
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
2526
<PackageReference Include="NUnit" Version="3.11.0" />
2627
<PackageReference Include="NUnit3TestAdapter" Version="3.13.0" />
2728
</ItemGroup>

0 commit comments

Comments
 (0)