mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-13 11:44:57 +00:00
Initial commit of JsonItemWrapperTest
This commit is contained in:
43
ICD.Common.Utils.Tests/Json/JsonItemWrapperTest.cs
Normal file
43
ICD.Common.Utils.Tests/Json/JsonItemWrapperTest.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using ICD.Common.Utils.Json;
|
||||
using NUnit.Framework;
|
||||
|
||||
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))]
|
||||
public void ItemTypeTest(object item, Type expected)
|
||||
{
|
||||
Assert.AreEqual(expected, new JsonItemWrapper(item).ItemType);
|
||||
}
|
||||
|
||||
[TestCase("")]
|
||||
[TestCase(1)]
|
||||
public void ItemTest(object item)
|
||||
{
|
||||
Assert.AreEqual(item, new JsonItemWrapper(item).Item);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WriteTest()
|
||||
{
|
||||
Assert.Inconclusive();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReadTest()
|
||||
{
|
||||
Assert.Inconclusive();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ namespace ICD.Common.Utils.Json
|
||||
/// <param name="writer">The <see cref="T:Newtonsoft.Json.JsonWriter"/> to write to.</param>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <param name="serializer">The calling serializer.</param>
|
||||
public override sealed void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
public sealed override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
@@ -42,7 +42,7 @@ namespace ICD.Common.Utils.Json
|
||||
/// <returns>
|
||||
/// The object value.
|
||||
/// </returns>
|
||||
public override sealed object ReadJson(JsonReader reader, Type objectType, object existingValue,
|
||||
public sealed override object ReadJson(JsonReader reader, Type objectType, object existingValue,
|
||||
JsonSerializer serializer)
|
||||
{
|
||||
if (reader.TokenType == JsonToken.Null)
|
||||
|
||||
Reference in New Issue
Block a user