public RunViaUnityEditorStrategy(ISolution solution,
                                         IUnitTestResultManager unitTestResultManager,
                                         UnityEditorProtocol editorProtocol,
                                         NUnitTestProvider unitTestProvider,
                                         IUnitTestElementIdFactory idFactory,
                                         ISolutionSaver riderSolutionSaver,
                                         UnityRefresher unityRefresher,
                                         NotificationsModel notificationsModel,
                                         UnityHost unityHost,
                                         ILogger logger,
                                         Lifetime lifetime,
                                         PackageValidator packageValidator
                                         )
        {
            mySolution = solution;
            myUnitTestResultManager = unitTestResultManager;
            myEditorProtocol        = editorProtocol;
            myUnitTestProvider      = unitTestProvider;
            myIDFactory             = idFactory;
            myRiderSolutionSaver    = riderSolutionSaver;
            myUnityRefresher        = unityRefresher;
            myNotificationsModel    = notificationsModel;
            myUnityHost             = unityHost;
            myLogger           = logger;
            myLifetime         = lifetime;
            myPackageValidator = packageValidator;
            myElements         = new WeakToWeakDictionary <UnitTestElementId, IUnitTestElement>();

            myUnityProcessId = new Property <int?>(lifetime, "RunViaUnityEditorStrategy.UnityProcessId");

            myUnityProcessId.ForEachValue_NotNull(lifetime, (lt, processId) =>
            {
                var process = myLogger.CatchIgnore(() => Process.GetProcessById(processId.NotNull()));
                if (process == null)
                {
                    myUnityProcessId.Value = null;
                    return;
                }

                process.EnableRaisingEvents = true;

                void OnProcessExited(object sender, EventArgs a) => myUnityProcessId.Value = null;
                lt.Bracket(() => process.Exited += OnProcessExited, () => process.Exited -= OnProcessExited);

                if (process.HasExited)
                {
                    myUnityProcessId.Value = null;
                }
            });

            myEditorProtocol.UnityModel.ViewNotNull(lifetime, (lt, model) =>
            {
                if (model.UnityProcessId.HasValue())
                {
                    myUnityProcessId.Value = model.UnityProcessId.Value;
                }

                model.UnityProcessId.FlowInto(lt, myUnityProcessId, id => id);
            });
        }
Ejemplo n.º 2
0
 public UnityTestElementFactory(IUnitTestElementIdFactory unitTestElementIdFactory,
                                UnityTestProvider unityTestProvider,
                                IUnitTestElementManager elementManager, UnityNUnitServiceProvider serviceProvider)
 {
     myUnitTestElementIdFactory = unitTestElementIdFactory;
     myElementManager           = elementManager;
     myServiceProvider          = serviceProvider;
     myElements         = new WeakToWeakDictionary <UnitTestElementId, IUnitTestElement>();
     myUnitTestProvider = unityTestProvider;
 }
Ejemplo n.º 3
0
 public RunViaUnityEditorStrategy(ISolution solution,
                                  IUnitTestResultManager unitTestResultManager,
                                  UnityEditorProtocol unityEditorProtocol,
                                  NUnitTestProvider unitTestProvider,
                                  IUnitTestElementIdFactory idFactory)
 {
     mySolution = solution;
     myUnitTestResultManager = unitTestResultManager;
     myUnityEditorProtocol   = unityEditorProtocol;
     myUnitTestProvider      = unitTestProvider;
     myIDFactory             = idFactory;
     myElements = new WeakToWeakDictionary <UnitTestElementId, IUnitTestElement>();
 }
 public RunViaUnityEditorStrategy(ISolution solution,
                                  IUnitTestResultManager unitTestResultManager,
                                  UnityEditorProtocol editorProtocol,
                                  NUnitTestProvider unitTestProvider,
                                  IUnitTestElementIdFactory idFactory,
                                  ISolutionSaver riderSolutionSaver,
                                  UnityRefresher unityRefresher,
                                  NotificationsModel notificationsModel,
                                  UnityHost unityHost,
                                  ILogger logger
                                  )
 {
     mySolution = solution;
     myUnitTestResultManager = unitTestResultManager;
     myEditorProtocol        = editorProtocol;
     myUnitTestProvider      = unitTestProvider;
     myIDFactory             = idFactory;
     myRiderSolutionSaver    = riderSolutionSaver;
     myUnityRefresher        = unityRefresher;
     myNotificationsModel    = notificationsModel;
     myUnityHost             = unityHost;
     myLogger   = logger;
     myElements = new WeakToWeakDictionary <UnitTestElementId, IUnitTestElement>();
 }