Add NewtonSoft.Json and red round-tip test

This commit is contained in:
Richard Buckle 2020-01-06 21:35:20 +00:00
Родитель 9ecaeb031c
Коммит f57441b3d0
2 изменённых файлов: 33 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,32 @@
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Highlighting;
using Newtonsoft.Json;
using NUnit.Framework;
namespace ICSharpCode.AvalonEdit.Tests.Highlighting
{
[TestFixture]
public class DeserializationTests
{
TextDocument document;
DocumentHighlighter highlighter;
[SetUp]
public void SetUp()
{
document = new TextDocument("using System.Text;\n\tstring text = SomeMethod();");
highlighter = new DocumentHighlighter(document, HighlightingManager.Instance.GetDefinition("C#"));
}
[Test]
public void TestRoundTripColor()
{
HighlightingColor color = highlighter.GetNamedColor("Comment");
string jsonString = JsonConvert.SerializeObject(color);
HighlightingColor color2 = JsonConvert.DeserializeObject<HighlightingColor>(jsonString);
Assert.AreEqual(color, color2);
}
}
}

Просмотреть файл

@ -22,6 +22,7 @@
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.13.0" />
</ItemGroup>