mirror of
https://github.com/AssetRipper/AssetRipper.git
synced 2025-12-11 20:15:29 +01:00
- Updated test dependencies: replaced `coverlet.collector` with `NUnit.Analyzers` for enhanced test analysis. - Refactored `TypeSignatureNameTests` to use instance setup and improved assertions with `Is.EqualTo`. - Simplified `AssetEqualityTests` by directly using `AssetEqualityComparer` in assertions. - Made `FileStreamTests` static and removed unused setup code. - Improved `RangeTests` by grouping assertions and using `Assert.EnterMultipleScope`. - Standardized random data generation with `TestContext.CurrentContext.Random`. - Removed unused `RandomStructEnumerable` class. - Refactored `DefaultJsonWalkerTests` and `DefaultYamlWalkerTests` for better readability and performance. - Removed redundant code in `VertexDataBlobTests` and simplified equivalence assertions. - General cleanup: removed unused namespaces, improved formatting, and aligned with modern C# conventions.
31 lines
821 B
C#
31 lines
821 B
C#
using AssetRipper.Assets;
|
|
using AssetRipper.Export.PrimaryContent;
|
|
using AssetRipper.SourceGenerated.Extensions;
|
|
using System.Text.Json.Nodes;
|
|
|
|
namespace AssetRipper.Tests.Traversal;
|
|
|
|
internal class DefaultJsonWalkerTests
|
|
{
|
|
[TestCaseSource(nameof(GetObjectTypes))]
|
|
public static void SerializedCustomObjectIsValidJson(Type type)
|
|
{
|
|
UnityObjectBase asset = AssetCreator.CreateUnsafe(type);
|
|
string json = new DefaultJsonWalker().SerializeStandard(asset);
|
|
JsonNode? node = JsonNode.Parse(json);
|
|
Assert.That(node, Is.Not.Null);
|
|
Assert.That(node, Is.TypeOf<JsonObject>());
|
|
}
|
|
|
|
private static Type[] GetObjectTypes() =>
|
|
[
|
|
typeof(SimpleObject),
|
|
typeof(ParentObject),
|
|
typeof(PrimitiveListObject),
|
|
typeof(ComponentListObject),
|
|
typeof(ListObject),
|
|
typeof(DictionaryObject),
|
|
typeof(PairObject),
|
|
];
|
|
}
|