Rasagar/Library/PackageCache/com.unity.test-framework/UnityEngine.TestRunner/NUnitExtensions/Commands/EnumerableApplyChangesToContextCommand.cs

35 lines
1.1 KiB
C#
Raw Normal View History

2024-08-26 13:07:20 -07:00
using System;
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
namespace UnityEngine.TestTools
{
internal class EnumerableApplyChangesToContextCommand : ApplyChangesToContextCommand, IEnumerableTestMethodCommand
{
public EnumerableApplyChangesToContextCommand(TestCommand innerCommand, IEnumerable<IApplyToContext> changes)
: base(innerCommand, changes) {}
public IEnumerable ExecuteEnumerable(ITestExecutionContext context)
{
ApplyChanges(context);
if (innerCommand is IEnumerableTestMethodCommand)
{
var executeEnumerable = ((IEnumerableTestMethodCommand)innerCommand).ExecuteEnumerable(context);
foreach (var iterator in executeEnumerable)
{
yield return iterator;
}
}
else
{
context.CurrentResult = innerCommand.Execute(context);
}
}
}
}