Exemplo n.º 1
0
        /// <summary>
        /// 输出指定命名空间下的测试结果
        /// </summary>
        /// <param name="unitTestNamespace"></param>
        /// <returns></returns>
        public IUnitTestManager Print(string unitTestNamespace)
        {
            IUnitTestResultManager unitTestResultManager = DependencyManager.Instance.Resolver <IUnitTestResultManager>();

            unitTestResultManager.PrintUnitTestResultByNamespace(unitTestNamespace);
            return(this);
        }
Exemplo n.º 2
0
 public RunViaUnityEditorStrategy(ISolution solution,
                                  IUnitTestResultManager unitTestResultManager, UnityEditorProtocol unityEditorProtocol)
 {
     mySolution = solution;
     myUnitTestResultManager = unitTestResultManager;
     myUnityEditorProtocol   = unityEditorProtocol;
 }
        public UnitTestAnimations(Lifetime lifetime, IUnitTestSessionConductor sessionConductor,
                                  IUnitTestResultManager resultsManager, Agent agent, IThreading threading)
        {
            this.resultsManager = resultsManager;
            this.agent          = agent;
            this.threading      = threading;
            var testSessionLifetimes = new Dictionary <IUnitTestSessionTreeViewModel, LifetimeDefinition>();

            sessionConductor.SessionOpened.Advise(lifetime, sessionView =>
            {
                var sessionLifetimeDefinition = Lifetimes.Define(lifetime, "Clippy::TestSession");
                testSessionLifetimes.Add(sessionView, sessionLifetimeDefinition);

                SubscribeToSessionLaunch(sessionLifetimeDefinition.Lifetime, sessionView.Session);
            });

            sessionConductor.SessionClosed.Advise(lifetime, sessionView =>
            {
                LifetimeDefinition sessionLifetimeDefinition;
                if (testSessionLifetimes.TryGetValue(sessionView, out sessionLifetimeDefinition))
                {
                    sessionLifetimeDefinition.Terminate();
                    testSessionLifetimes.Remove(sessionView);
                }
            });
        }
        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);
            });
        }
        public RunViaUnityEditorStrategy(ISolution solution,
                                         IUnitTestResultManager unitTestResultManager,
                                         BackendUnityHost backendUnityHost,
                                         NUnitTestProvider unitTestProvider,
                                         IUnitTestElementIdFactory idFactory,
                                         ISolutionSaver riderSolutionSaver,
                                         UnityRefresher unityRefresher,
                                         NotificationsModel notificationsModel,
                                         FrontendBackendHost frontendBackendHost,
                                         ILogger logger,
                                         Lifetime lifetime,
                                         PackageValidator packageValidator,
                                         JetBrains.Application.ActivityTrackingNew.UsageStatistics usageStatistics)
        {
            mySolution = solution;
            myUnitTestResultManager = unitTestResultManager;
            myBackendUnityHost      = backendUnityHost;
            myUnitTestProvider      = unitTestProvider;
            myIDFactory             = idFactory;
            myRiderSolutionSaver    = riderSolutionSaver;
            myUnityRefresher        = unityRefresher;
            myNotificationsModel    = notificationsModel;
            myFrontendBackendHost   = frontendBackendHost;
            myLogger           = logger;
            myLifetime         = lifetime;
            myPackageValidator = packageValidator;
            myUsageStatistics  = usageStatistics;

            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;
                }
            });

            myBackendUnityHost.BackendUnityModel.ViewNotNull(lifetime, (lt, model) =>
            {
                // This will set the current value, if it exists
                model.UnityApplicationData.FlowInto(lt, myUnityProcessId, data => data.UnityProcessId);
            });
        }
Exemplo n.º 6
0
 public MspecDotNetTestRunStrategy(
     IJsonBasedUnitTestServerFactory serverFactory,
     MspecTestElementMapperFactory mapperFactory,
     IDotNetTestCaseMap testCaseMap,
     IUnitTestResultManager resultManager,
     ISolutionProcessStartInfoPatcher processStartInfoPatcher,
     ILogger logger)
     : base(serverFactory, mapperFactory, testCaseMap, resultManager, processStartInfoPatcher, logger)
 {
 }
Exemplo n.º 7
0
        public LinkedTestInvalidator(
            Lifetime lifetime,
            ChangedTypesProvider changedTypesProvider,
            LinkedTypesService linkedTypesService,
            IUnitTestResultManager unitTestResultManager)
        {
            _linkedTypesService    = linkedTypesService;
            _unitTestResultManager = unitTestResultManager;

            changedTypesProvider.TypesChanged.Advise(lifetime, OnChanged);
        }
Exemplo n.º 8
0
        public LinkedTestInvalidator(
            Lifetime lifetime,
            ChangedTypesProvider changedTypesProvider,
            IUnitTestElementStuff unitTestElementStuff,
            IUnitTestResultManager unitTestResultManager)
        {
            _unitTestElementStuff  = unitTestElementStuff;
            _unitTestResultManager = unitTestResultManager;

            changedTypesProvider.TypesChanged.Advise(lifetime, OnChanged);
        }
Exemplo n.º 9
0
 public MspecDotNetVsTestRunStrategy(
     IJsonBasedUnitTestServerFactory serverFactory,
     MspecTestElementMapperFactory mapperFactory,
     DefaultDotNetVsTestRunSettingsProvider runSettingsProvider,
     IDotNetVsTestCaseMapProvider testCaseMapProvider,
     IUnitTestResultManager resultManager,
     ISolutionProcessStartInfoPatcher processStartInfoPatcher,
     ILogger logger,
     IUnitTestingSettings unitTestingSettings,
     IEnumerable <IRunSettingsPostProcessor> runSettingsPostProcessors)
     : base(serverFactory, mapperFactory, runSettingsProvider, testCaseMapProvider, resultManager, processStartInfoPatcher, logger, unitTestingSettings, runSettingsPostProcessors)
 {
 }
Exemplo n.º 10
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>();
 }
Exemplo n.º 11
0
        public TestRunEventGenerator(Lifetime lifetime,
                                     IUnitTestSessionConductor sessionManager,
                                     IUnitTestResultManager resultManager,
                                     IThreading threading,
                                     IRSEnv env,
                                     IMessageBus messageBus,
                                     IDateUtils dateUtils)
            : base(env, messageBus, dateUtils, threading)
        {
            _resultManager = resultManager;
            _threading     = threading;

            var testSessionLifetimes = new Dictionary <IUnitTestSessionTreeViewModelBase, LifetimeDefinition>();

            sessionManager.SessionOpened.Advise(
                lifetime,
                sessionView =>
            {
                var sessionLifetimeDefinition =
                    Lifetimes.Define(lifetime, "KaVE::TestRunEventGenerator");
                testSessionLifetimes.Add(sessionView, sessionLifetimeDefinition);

                SubscribeToSessionLaunch(sessionLifetimeDefinition.Lifetime, sessionView.Session);
            });

            sessionManager.SessionClosed.Advise(
                lifetime,
                sessionView =>
            {
                LifetimeDefinition sessionLifetimeDefinition;
                if (testSessionLifetimes.TryGetValue(sessionView, out sessionLifetimeDefinition))
                {
                    sessionLifetimeDefinition.Terminate();
                    testSessionLifetimes.Remove(sessionView);
                }
            });
        }
 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>();
 }
 protected ITaskRunnerHostController CreateTaskRunnerHostController(IUnitTestLaunchManager launchManager, IUnitTestResultManager resultManager, IUnitTestAgentManager agentManager, IUnitTestLaunch launch, IUnitTestSessionManager sessionManager, int port)
 {
     return new ProcessTaskRunnerHostController(port, sessionManager, launchManager, resultManager, agentManager, launch, Logger.GetLogger(typeof(UnitTestTaskRunnerTestBase)));
 }
Exemplo n.º 14
0
        public IUnitTestManager Run(string unitTestNamespace)
        {
            IUnitTestCaseManager         unitTestCaseManager       = DependencyManager.Instance.Resolver <IUnitTestCaseManager>();
            IUnitTestResultManager       unitTestResultManager     = DependencyManager.Instance.Resolver <IUnitTestResultManager>();
            List <UnitTestCaseContainer> unitTestCaseContainerList = unitTestCaseManager.GetUnitTestCaseByNamespace(unitTestNamespace);

            foreach (UnitTestCaseContainer unitTestCase in unitTestCaseContainerList)
            {
                object    unitTestInstance             = DependencyManager.Instance.Resolver(unitTestCase.UnitTestClassType);
                object    unitTestInstanceMethodReturn = null;
                Exception tmpException = null;
                UnitTestResultContainer unitTestResult = new UnitTestResultContainer
                {
                    ClassName         = unitTestCase.ClassName,
                    MethodName        = unitTestCase.MethodName,
                    UnitTestNamespace = unitTestCase.UnitTestNamespace,
                    MethodParas       = unitTestCase.MethodParas
                };
                try
                {
                    unitTestInstanceMethodReturn = unitTestInstance.GetType().GetMethod(unitTestCase.MethodName).Invoke(unitTestInstance, unitTestCase.MethodParas.ToArray());
                }
                catch (Exception ex)
                {
                    tmpException = ex;
                }

                switch (unitTestCase.CaseAssertType)
                {
                case UnitTestCaseAssertType.AssertEquals:
                    if (unitTestInstanceMethodReturn.Equals(unitTestCase.MethodReturn))
                    {
                        unitTestResult.Result = true;
                    }
                    else
                    {
                        SetUnitTestResultFalse(unitTestResult, tmpException);
                    }
                    break;

                case UnitTestCaseAssertType.AssertSame:
                    if (unitTestInstanceMethodReturn == unitTestCase.MethodReturn)
                    {
                        unitTestResult.Result = true;
                    }
                    else
                    {
                        SetUnitTestResultFalse(unitTestResult, tmpException);
                    }
                    break;

                case UnitTestCaseAssertType.AssertFalse:
                    if (unitTestInstanceMethodReturn is bool && !(bool)unitTestInstanceMethodReturn)
                    {
                        unitTestResult.Result = true;
                    }
                    else
                    {
                        SetUnitTestResultFalse(unitTestResult, tmpException);
                    }
                    break;

                case UnitTestCaseAssertType.AssertTrue:
                    if (unitTestInstanceMethodReturn is bool && (bool)unitTestInstanceMethodReturn)
                    {
                        unitTestResult.Result = true;
                    }
                    else
                    {
                        SetUnitTestResultFalse(unitTestResult, tmpException);
                    }
                    break;

                case UnitTestCaseAssertType.AssertNull:
                    if (unitTestInstanceMethodReturn == null)
                    {
                        unitTestResult.Result = true;
                    }
                    else
                    {
                        SetUnitTestResultFalse(unitTestResult, tmpException);
                    }
                    break;

                case UnitTestCaseAssertType.AssertNotNull:
                    if (unitTestInstanceMethodReturn != null)
                    {
                        unitTestResult.Result = true;
                    }
                    else
                    {
                        SetUnitTestResultFalse(unitTestResult, tmpException);
                    }
                    break;

                case UnitTestCaseAssertType.AssertNotSame:
                    if (unitTestInstanceMethodReturn != unitTestCase.MethodReturn)
                    {
                        unitTestResult.Result = true;
                    }
                    else
                    {
                        SetUnitTestResultFalse(unitTestResult, tmpException);
                    }
                    break;
                }
                unitTestResultManager.AddUnitTestResult(unitTestResult);
            }
            return(this);
        }
 public OutOfProcessTestRunStrategy(IUnitTestAgentManager agentManager, IUnitTestResultManager resultManager)
     : base(agentManager, resultManager, new RemoteTaskRunnerInfo(BurplessTestProvider.RunnerId, typeof(TaskRunner)))
 {
 }
Exemplo n.º 16
0
 public MspecOutOfProcessUnitTestRunStrategy(IUnitTestAgentManager agentManager, IUnitTestResultManager resultManager)
     : base(agentManager, resultManager, new RemoteTaskRunnerInfo(MspecTaskRunner.RunnerId, typeof(MspecTaskRunner)))
 {
 }
 public ExtendedDebugTaskRunnerHostController(ILogger logger, IUnitTestLaunchManager launchManager, IUnitTestResultManager resultManager, IUnitTestAgentManager agentManager, IVsDebuggerFacade debuggerFacade, DTE dte, IUnitTestLaunch launch, int portNumber)
     : base(logger, launchManager, resultManager, agentManager, debuggerFacade, dte, launch, portNumber)
 {
 }
Exemplo n.º 18
0
 protected ITaskRunnerHostController CreateTaskRunnerHostController(IUnitTestLaunchManager launchManager, IUnitTestResultManager resultManager, IUnitTestAgentManager agentManager, IUnitTestLaunch launch, IUnitTestSessionManager sessionManager, int port)
 {
     return(new ProcessTaskRunnerHostController(port, sessionManager, launchManager, resultManager, agentManager, launch, Logger.GetLogger(typeof(UnitTestTaskRunnerTestBase))));
 }