From e1c267a8eb4f974e004d190538f26d017dd13c31 Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Wed, 18 Oct 2017 14:47:47 -0400 Subject: [PATCH] Initial commit of JsonItemWrapperTest --- .../Json/JsonItemWrapperTest.cs | 43 +++++++++++++++++++ .../Json/AbstractGenericJsonConverter.cs | 4 +- 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 ICD.Common.Utils.Tests/Json/JsonItemWrapperTest.cs diff --git a/ICD.Common.Utils.Tests/Json/JsonItemWrapperTest.cs b/ICD.Common.Utils.Tests/Json/JsonItemWrapperTest.cs new file mode 100644 index 0000000..0a98c87 --- /dev/null +++ b/ICD.Common.Utils.Tests/Json/JsonItemWrapperTest.cs @@ -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(); + } + } +} diff --git a/ICD.Common.Utils/Json/AbstractGenericJsonConverter.cs b/ICD.Common.Utils/Json/AbstractGenericJsonConverter.cs index 9f3e44a..900b1ce 100644 --- a/ICD.Common.Utils/Json/AbstractGenericJsonConverter.cs +++ b/ICD.Common.Utils/Json/AbstractGenericJsonConverter.cs @@ -12,7 +12,7 @@ namespace ICD.Common.Utils.Json /// The to write to. /// The value. /// The calling serializer. - 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 /// /// The object value. /// - 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)