1
0

Unit-Test erweitert, NetRevisionTask aktualisiert, ExceptionTests hinzugefügt...

This commit is contained in:
2021-11-28 11:21:40 +01:00
parent adb140b1a3
commit 6f6b79c88c
12 changed files with 350 additions and 16 deletions

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections;
using AMWD.Common.Tests.Utils;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
@@ -7,6 +8,7 @@ using Newtonsoft.Json.Linq;
namespace AMWD.Common.Tests.Extensions
{
[TestClass]
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public class JsonExtensionsTests
{
[TestMethod]
@@ -303,5 +305,37 @@ namespace AMWD.Common.Tests.Extensions
Assert.AreEqual("Well Done", notExistingOnSubLevel);
Assert.AreEqual(13, notExistingLevel);
}
[TestMethod]
public void ShouldReturnNull()
{
// arrange
object obj = null;
IEnumerable list = null;
JObject jObj = null;
// act
var objTest = obj.ConvertToJObject();
var listTest = list.ConvertToJArray();
object getTest = jObj.GetValue<object>("Nothing");
// assert
Assert.IsNull(objTest);
Assert.IsNull(listTest);
Assert.IsNull(getTest);
}
[TestMethod]
public void ShouldHandleSerializationError()
{
// arrange
var obj = new JsonErrorClass();
// act
string json = obj.SerializeJson();
// assert
Assert.AreEqual("{}", json);
}
}
}