mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-15 20:54:58 +00:00
Improvements to JsonItemWrapper serialization
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ICD.Common.Utils.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace ICD.Common.Utils.Tests.Json
|
||||
@@ -7,12 +9,6 @@ namespace ICD.Common.Utils.Tests.Json
|
||||
[TestFixture]
|
||||
public sealed class JsonItemWrapperTest
|
||||
{
|
||||
[TestCase(null, null)]
|
||||
public void ItemTypeStringTest(object item, string expected)
|
||||
{
|
||||
Assert.AreEqual(expected, new JsonItemWrapper(item).ItemTypeString);
|
||||
}
|
||||
|
||||
[TestCase(null, null)]
|
||||
[TestCase("", typeof(string))]
|
||||
[TestCase(1, typeof(int))]
|
||||
@@ -31,13 +27,22 @@ namespace ICD.Common.Utils.Tests.Json
|
||||
[Test]
|
||||
public void WriteTest()
|
||||
{
|
||||
JsonItemWrapper wrapper = new JsonItemWrapper(new List<int> {1, 2, 3});
|
||||
string json = JsonUtils.Serialize(wrapper.Write);
|
||||
|
||||
Assert.Inconclusive();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReadTest()
|
||||
{
|
||||
Assert.Inconclusive();
|
||||
const string json = "{\"t\":\"System.Collections.Generic.List`1[[System.Int32, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]\",\"i\":\"[1,2,3]\"}";
|
||||
|
||||
JObject jObject = JObject.Parse(json);
|
||||
List<int> wrappedObject = JsonItemWrapper.ReadToObject(jObject) as List<int>;
|
||||
|
||||
Assert.NotNull(wrappedObject);
|
||||
Assert.AreEqual(3, wrappedObject.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user