Skip to content

Commit 0f5f050

Browse files
Fix issues in automated tests
A few failures had somehow slipped which were all bugs in the tests themselves (one because of a file move, two others were testing the wrong expected data)
1 parent 2b2347f commit 0f5f050

1 file changed

Lines changed: 13 additions & 37 deletions

File tree

UnityDataTool.Tests/SerializedFileCommandTests.cs

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ public async Task Header_InvalidFile_ReturnsError()
425425
[Test]
426426
public async Task Header_ArchiveFile_ReturnsError()
427427
{
428-
var legacyDir = Path.Combine(TestContext.CurrentContext.TestDirectory, "Data", "LegacyFormats");
428+
var legacyDir = Path.Combine(TestContext.CurrentContext.TestDirectory, "Data", "LegacyFormats", "AssetBundles");
429429
var archivePath = Path.Combine(legacyDir, "alienprefab");
430430

431431
if (!File.Exists(archivePath))
@@ -524,10 +524,10 @@ public async Task Metadata_TextOutput_SucceedsAndContainsExpectedFields()
524524
var output = sw.ToString();
525525

526526
// Basic sanity checks on text output; exact formatting is left flexible,
527-
// but the output should mention metadata and TypeTree-related information.
528-
StringAssert.Contains("Metadata", output, "Text output should mention metadata");
529-
StringAssert.Contains("Type", output, "Text output should mention type information");
530-
StringAssert.Contains("Tree", output, "Text output should mention TypeTree information");
527+
// but the output should mention certain info.
528+
StringAssert.Contains("Unity Version", output, "Text output should mention Unity Version");
529+
StringAssert.Contains("TypeTree", output, "Text output should mention TypeTree information");
530+
StringAssert.Contains("Target Platform", output, "Text output should mention Target Platform information");
531531
}
532532
finally
533533
{
@@ -575,45 +575,21 @@ public async Task Metadata_JsonOutput_SucceedsAndContainsTypeTreeInfo()
575575
Assert.AreEqual(JsonValueKind.Object, root.ValueKind, "Root JSON element should be an object");
576576

577577
// Validate the presence of some core metadata properties.
578-
Assert.IsTrue(root.TryGetProperty("filePath", out _)
579-
|| root.TryGetProperty("path", out _),
580-
"JSON metadata should contain a file path property");
578+
Assert.IsTrue(root.TryGetProperty("targetPlatform", out _),
579+
"JSON metadata should contain a targetPlatform property");
581580

582-
Assert.IsTrue(root.TryGetProperty("unityVersion", out _)
583-
|| root.TryGetProperty("version", out _),
581+
Assert.IsTrue(root.TryGetProperty("unityVersion", out _),
584582
"JSON metadata should contain a Unity version property");
585583

584+
Assert.IsTrue(root.TryGetProperty("typeTreeCount", out _),
585+
"JSON metadata should contain a typeTreeCount property");
586+
586587
// Validate TypeTree-related information: either a count or an array of TypeTrees.
587588
JsonElement typeTreesElement;
588-
bool hasTypeTrees =
589-
root.TryGetProperty("typeTrees", out typeTreesElement) ||
590-
root.TryGetProperty("typeTree", out typeTreesElement) ||
591-
root.TryGetProperty("typeTreeInfos", out typeTreesElement);
589+
bool hasTypeTrees = root.TryGetProperty("typeTrees", out typeTreesElement);
592590

593591
Assert.IsTrue(hasTypeTrees, "JSON metadata should contain TypeTree information");
594-
595-
if (typeTreesElement.ValueKind == JsonValueKind.Array)
596-
{
597-
Assert.Greater(typeTreesElement.GetArrayLength(), 0, "TypeTree array should contain at least one entry");
598-
599-
var first = typeTreesElement[0];
600-
Assert.AreEqual(JsonValueKind.Object, first.ValueKind, "Each TypeTree entry should be an object");
601-
602-
// Check for some typical fields on a TypeTree entry (IDs/counts/arrays).
603-
Assert.IsTrue(first.TryGetProperty("typeId", out _)
604-
|| first.TryGetProperty("classId", out _),
605-
"TypeTree entry should contain a type or class ID");
606-
607-
Assert.IsTrue(first.TryGetProperty("nodes", out var nodesElement)
608-
? nodesElement.ValueKind == JsonValueKind.Array
609-
: true,
610-
"If present, TypeTree nodes should be an array");
611-
}
612-
else if (typeTreesElement.ValueKind == JsonValueKind.Number)
613-
{
614-
// Some formats may expose only a count.
615-
Assert.Greater(typeTreesElement.GetInt32(), 0, "TypeTree count should be greater than zero");
616-
}
592+
Assert.That(typeTreesElement.ValueKind, Is.EqualTo(JsonValueKind.Array), "TypeTree information should be an array");
617593
}
618594
finally
619595
{

0 commit comments

Comments
 (0)