Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > IT форум > Помощь студентам
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 05.06.2022, 07:10   #1
Glori4
Новичок
Джуниор
 
Регистрация: 05.06.2022
Сообщений: 1
Сообщение Unity

Здравствуйте, помогите пожалуйста решить проблему следующего характера. Установил Unity, каждый раз когда пытаюсь сделать "проект" , предлагается войти в безопасный режим, т.к. что то со скриптом, не дает выполнять практически все функции. Прошу помочь.
Вот сам код:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using UnityEngine.TestTools;
using UnityEngine.TestTools.Logging;
using UnityEngine.TestTools.TestRunner;

namespace UnityEngine.TestRunner.NUnitExtensi ons.Runner
{
class UnityLogCheckDelegatingCommand : DelegatingTestCommand, IEnumerableTestMethodCommand
{
static Dictionary<object, bool?> s_AttributeCache = new Dictionary<object, bool?>();

public UnityLogCheckDelegatingCommand(Test Command innerCommand)
: base(innerCommand) {}

public override TestResult Execute(ITestExecutionContext context)
{
using (var logScope = new LogScope())
{
if (ExecuteAndCheckLog(logScope, context.CurrentResult, () => innerCommand.Execute(context)))
PostTestValidation(logScope, innerCommand, context.CurrentResult);
}

return context.CurrentResult;
}

public IEnumerable ExecuteEnumerable(ITestExecutionCon text context)
{
if (!(innerCommand is IEnumerableTestMethodCommand enumerableTestMethodCommand))
{
Execute(context);
yield break;
}

using (var logScope = new LogScope())
{
IEnumerable executeEnumerable = null;

if (!ExecuteAndCheckLog(logScope, context.CurrentResult,
() => executeEnumerable = enumerableTestMethodCommand.Execute Enumerable(context)))
yield break;

foreach (var step in executeEnumerable)
{
// do not check expected logs here - we want to permit expecting and receiving messages to run
// across frames. (but we do always want to catch a fail immediately.)
if (!CheckFailingLogs(logScope, context.CurrentResult))
yield break;

yield return step;
}

if (!CheckLogs(context.CurrentResult, logScope))
yield break;

PostTestValidation(logScope, innerCommand, context.CurrentResult);
}
}

static bool CaptureException(TestResult result, Action action)
{
try
{
action();
return true;
}
catch (Exception e)
{
result.RecordException(e);
return false;
}
}

static bool ExecuteAndCheckLog(LogScope logScope, TestResult result, Action action)
=> CaptureException(result, action) && CheckLogs(result, logScope);

static void PostTestValidation(LogScope logScope, TestCommand command, TestResult result)
{
if (MustExpect(command.Test.Method.Met hodInfo))
CaptureException(result, logScope.NoUnexpectedReceived);
}

static bool CheckLogs(TestResult result, LogScope logScope)
=> CheckFailingLogs(logScope, result) && CheckExpectedLogs(logScope, result);

static bool CheckFailingLogs(LogScope logScope, TestResult result)
{
if (!logScope.AnyFailingLogs())
return true;

var failingLog = logScope.FailingLogs.First();
result.RecordException(new UnhandledLogMessageException(failin gLog));
return false;
}

static bool CheckExpectedLogs(LogScope logScope, TestResult result)
{
if (!logScope.ExpectedLogs.Any())
return true;

var expectedLog = logScope.ExpectedLogs.Peek();
result.RecordException(new UnexpectedLogMessageException(expec tedLog));
return false;
}

static bool MustExpect(MemberInfo method)
{
// method

var methodAttr = method.GetCustomAttributes<TestMust ExpectAllLogsAttribute>(true).First OrDefault();
if (methodAttr != null)
return methodAttr.MustExpect;

// fixture

var fixture = method.DeclaringType;
if (!s_AttributeCache.TryGetValue(fixt ure, out var mustExpect))
{
var fixtureAttr = fixture.GetCustomAttributes<TestMus tExpectAllLogsAttribute>(true).Firs tOrDefault();
mustExpect = s_AttributeCache[fixture] = fixtureAttr?.MustExpect;
}

if (mustExpect != null)
return mustExpect.Value;

// assembly

var assembly = fixture.Assembly;
if (!s_AttributeCache.TryGetValue(asse mbly, out mustExpect))
{
var assemblyAttr = assembly.GetCustomAttributes<TestMu stExpectAllLogsAttribute>().FirstOr Default();
mustExpect = s_AttributeCache[assembly] = assemblyAttr?.MustExpect;
}

return mustExpect == true;
}
}
}
Изображения
Тип файла: jpg 2022-06-05_06-47-50.jpg (80.0 Кб, 0 просмотров)

Последний раз редактировалось Glori4; 05.06.2022 в 07:13.
Glori4 вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
С# unity Пётр112 Помощь студентам 1 25.01.2022 22:02
Unity Шатун C# (си шарп) 0 19.06.2021 10:30
Unity Leyla84 Помощь студентам 0 01.02.2014 00:04
Unity 3D bumer7721 Gamedev - cоздание игр: Unity, OpenGL, DirectX 1 10.06.2011 19:19
Unity 3D bumer7721 Помощь студентам 0 10.06.2011 16:16