Unit-Test erweitert, NetRevisionTask aktualisiert, ExceptionTests hinzugefügt...
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user