30 lines
1.3 KiB
C#
30 lines
1.3 KiB
C#
using NUnit.Framework;
|
|
using Strata.RxNorm.Biz.Utilities;
|
|
using System.Collections.Generic;
|
|
using System.Text.Json;
|
|
|
|
namespace Strata.RxNorm.Biz.Test.Unit.Utilities
|
|
{
|
|
[TestFixture]
|
|
public class LogUtilsExtensionsTests
|
|
{
|
|
[TestCaseSource(nameof(TestCases))]
|
|
public void Test(object input, object expected)
|
|
{
|
|
var dictionary = LogUtilsExtensions.ToDictionary<object>(input);
|
|
var expectedStr = JsonSerializer.Serialize(expected);
|
|
var actualStr = JsonSerializer.Serialize(dictionary);
|
|
Assert.That(actualStr, Is.EqualTo(expectedStr));
|
|
}
|
|
|
|
public static IEnumerable<TestCaseData> TestCases()
|
|
{
|
|
yield return new TestCaseData(new { a = 1, b = "test" }, new Dictionary<string, object> { { "a", 1 }, { "b", "test" } });
|
|
yield return new TestCaseData(new { a = 1, b = (string)null }, new Dictionary<string, object> { { "a", 1 }, { "b", null } });
|
|
yield return new TestCaseData(new { a = 1, b = new { c = 2 } }, new Dictionary<string, object> { { "a", 1 }, { "b", new Dictionary<string, object> { { "c", 2 } } } });
|
|
yield return new TestCaseData(123, new Dictionary<string, object> { { "object", 123 } });
|
|
yield return new TestCaseData("test", new Dictionary<string, object> { { "object", "test" } });
|
|
}
|
|
}
|
|
}
|