Пример #1
0
        public void DiscoverTests(IEnumerable <string> sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink)
        {
            try
            {
                ValidateArg.NotNull(sources, nameof(sources));
                ValidateArg.NotNull(discoveryContext, nameof(discoveryContext));
                ValidateArg.NotNull(logger, nameof(logger));
                ValidateArg.NotNull(discoverySink, nameof(discoverySink));

                _vsLogger = logger;
                _engine.Logger.MessageEvent += MessageEventHandler;
                TestCycleCollection tests = _engine.DiscoverTests(sources);
                _engine.Logger.MessageEvent -= MessageEventHandler;

                foreach (string source in sources)
                {
                    DiaSessionCache.PopulateCache(source);
                }

                foreach (MUF.ITestMethodContext context in tests.TestContextLookup.Values)
                {
                    TestCase        testCase = AdpaterUtilites.ConvertToTestCase(context);
                    INavigationData nav      = DiaSessionCache.GetNavDataForMethod(testCase.Source, context.DeclaringType.FullName, context.MethodInfo.Name);
                    testCase.CodeFilePath = nav.FileName ?? string.Empty;
                    testCase.LineNumber   = nav.MinLineNumber;

                    discoverySink.SendTestCase(testCase);
                }
            }
            catch (Exception e)
            {
                _engine.Logger.RecordMessage(MUF.MessageLevel.Error, e.ToString());
            }
        }