using System;
using System.Text;
using KellermanSoftware.CompareNetObjects;
using MfGames.TestSetup;
using Newtonsoft.Json;
using Xunit.Abstractions;
using Xunit.Sdk;
namespace Nitride.IO.Tests;
public abstract class NitrideIOTestBase : TestBase<NitrideIOTestContext>
{
protected NitrideIOTestBase(ITestOutputHelper output)
: base(output)
}
protected void CompareObjects<T>(T expected, T actual)
where T : class
CompareLogic compare = new()
Config =
MaxDifferences = int.MaxValue,
},
};
ComparisonResult comparison = compare.Compare(expected, actual);
if (comparison.AreEqual)
return;
// Format the error message.
StringBuilder message = new();
message.AppendLine("# Expected");
message.AppendLine();
message.AppendLine(JsonConvert.SerializeObject(expected, Formatting.Indented));
message.Append("# Actual");
message.AppendLine(JsonConvert.SerializeObject(actual, Formatting.Indented));
message.Append("# Results");
message.AppendLine(comparison.DifferencesString);
throw new XunitException(message.ToString());