Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Assets/Tests/Editor/ThirdPartyToolMigrationFileServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ public void ThirdPartyToolMigrationPreview_WhenInputFilePathsMutate_KeepsSnapsho
Assert.That(preview.FilePaths, Is.EqualTo(new[] { "Assets/VendorTools/HelloTool.cs" }));
}

[Test]
public void ThirdPartyToolMigrationPreview_WhenFilePathsIsNull_Throws()
{
// Verifies that preview snapshots fail fast when file paths are missing.
Assert.Throws<ArgumentNullException>(() => new ThirdPartyToolMigrationPreview(0, 0, null));
}

[Test]
public void ThirdPartyToolMigrationResult_WhenInputFilePathsMutate_KeepsSnapshot()
{
Expand All @@ -53,6 +60,13 @@ public void ThirdPartyToolMigrationResult_WhenInputFilePathsMutate_KeepsSnapshot
Assert.That(result.FilePaths, Is.EqualTo(new[] { "Assets/VendorTools/HelloTool.cs" }));
}

[Test]
public void ThirdPartyToolMigrationResult_WhenFilePathsIsNull_Throws()
{
// Verifies that result snapshots fail fast when file paths are missing.
Assert.Throws<ArgumentNullException>(() => new ThirdPartyToolMigrationResult(0, 0, null));
}

[Test]
public void ThirdPartyToolMigrationSourceFileCache_WhenFileIsReadTwice_UsesCachedSource()
{
Expand Down
43 changes: 43 additions & 0 deletions Assets/Tests/Editor/ThirdPartyToolMigrationRulesTests.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Linq;

using NUnit.Framework;
Expand All @@ -12,6 +13,48 @@ namespace io.github.hatayama.UnityCliLoop.Tests.Editor
/// </summary>
public sealed class ThirdPartyToolMigrationRulesTests
{
[Test]
public void RemovedLegacyPlayerLoopTimingSignature_WhenOriginalParametersIsNull_Throws()
{
// Verifies that timing signatures fail fast when original parameter snapshots are missing.
Assert.Throws<ArgumentNullException>(() => new RemovedLegacyPlayerLoopTimingSignature(
"Run",
"SampleTool",
null,
Array.Empty<RemovedLegacyPlayerLoopTimingParameter>()));
}

[Test]
public void RemovedLegacyPlayerLoopTimingSignature_WhenRemovedParametersIsNull_Throws()
{
// Verifies that timing signatures fail fast when removed parameter snapshots are missing.
Assert.Throws<ArgumentNullException>(() => new RemovedLegacyPlayerLoopTimingSignature(
"Run",
"SampleTool",
Array.Empty<LegacyPlayerLoopTimingParameterDeclaration>(),
null));
}

[Test]
public void ThirdPartyToolMigrationContentResult_WhenContentIsNull_Throws()
{
// Verifies that migration content results fail fast when rewritten content is missing.
Assert.Throws<ArgumentNullException>(() => new ThirdPartyToolMigrationContentResult(
null,
0,
Array.Empty<RemovedLegacyPlayerLoopTimingSignature>()));
}

[Test]
public void ThirdPartyToolMigrationContentResult_WhenRemovedSignaturesIsNull_Throws()
{
// Verifies that migration content results fail fast when removed timing signatures are missing.
Assert.Throws<ArgumentNullException>(() => new ThirdPartyToolMigrationContentResult(
string.Empty,
0,
null));
}

[Test]
public void MigrateCSharpSource_WhenLegacyToolApiIsUsed_RewritesToV3Contracts()
{
Expand Down
7 changes: 6 additions & 1 deletion Packages/src/Editor/Domain/ThirdPartyToolMigrationData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ internal static class ThirdPartyToolMigrationFilePathSnapshot
{
internal static string[] Copy(string[] filePaths)
{
if (filePaths == null || filePaths.Length == 0)
if (filePaths == null)
{
throw new ArgumentNullException(nameof(filePaths));
}

if (filePaths.Length == 0)
{
return Array.Empty<string>();
}
Expand Down
9 changes: 5 additions & 4 deletions Packages/src/Editor/Domain/ThirdPartyToolMigrationRuleData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ public RemovedLegacyPlayerLoopTimingSignature(
MethodName = methodName;
DeclaringTypeName = declaringTypeName;
OriginalParameters =
originalParameters ?? Array.Empty<LegacyPlayerLoopTimingParameterDeclaration>();
RemovedParameters = removedParameters ?? Array.Empty<RemovedLegacyPlayerLoopTimingParameter>();
originalParameters ?? throw new ArgumentNullException(nameof(originalParameters));
RemovedParameters =
removedParameters ?? throw new ArgumentNullException(nameof(removedParameters));
}

public string MethodName { get; }
Expand Down Expand Up @@ -93,11 +94,11 @@ public ThirdPartyToolMigrationContentResult(
removedPlayerLoopTimingSignatures != null,
"removedPlayerLoopTimingSignatures must not be null");

Content = content ?? string.Empty;
Content = content ?? throw new ArgumentNullException(nameof(content));
ReplacementCount = replacementCount;
RemovedPlayerLoopTimingSignatures =
removedPlayerLoopTimingSignatures ??
Array.Empty<RemovedLegacyPlayerLoopTimingSignature>();
throw new ArgumentNullException(nameof(removedPlayerLoopTimingSignatures));
}

public string Content { get; }
Expand Down
Loading