/
TON618OFF
/
Unity-Project-RTU
Обзор
Документация
Войти
/
TON618OFF
/
Unity-Project-RTU
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Library/PackageCache/com.unity.test-framework@1.1.33/UnityEngine.TestRunner/NUnitExtensions/Attributes/TestEnumerator.cs
94 строки
2 KB
TON618OFF
release
03 окт 2024, 22:20
03 окт 2024, 22:20
7c70e9f
Код
Авторство
О чём код?
using System; using System.Collections; using NUnit.Framework; using NUnit.Framework.Interfaces; using NUnit.Framework.Internal; using UnityEngine.TestRunner.NUnitExtensions; namespace UnityEngine.TestTools { internal class TestEnumerator { private readonly ITestExecutionContext m_Context; private static IEnumerator m_TestEnumerator; public static IEnumerator Enumerator { get { return m_TestEnumerator; } } public static void Reset() { m_TestEnumerator = null; } public TestEnumerator(ITestExecutionContext context, IEnumerator testEnumerator) { m_Context = context; m_TestEnumerator = testEnumerator; } public IEnumerator Execute() { m_Context.CurrentResult.SetResult(ResultState.Success); return Execute(m_TestEnumerator, new EnumeratorContext(m_Context)); } private IEnumerator Execute(IEnumerator enumerator, EnumeratorContext context) { while (true) { if (context.ExceptionWasRecorded) { break; } try { if (!enumerator.MoveNext()) { break; } } catch (Exception ex) { context.RecordExceptionWithHint(ex); break; } if (enumerator.Current is IEnumerator nestedEnumerator) { yield return Execute(nestedEnumerator, context); } else { yield return enumerator.Current; } } } private class EnumeratorContext { private readonly ITestExecutionContext m_Context; public EnumeratorContext(ITestExecutionContext context) { m_Context = context; } public bool ExceptionWasRecorded { get; private set; } public void RecordExceptionWithHint(Exception ex) { if (ExceptionWasRecorded) { return; } m_Context.CurrentResult.RecordException(ex); ExceptionWasRecorded = true; } } } }