Exemplo n.º 1
0
            private async Task UpdateTestCasesAsync(ProjectAnalyzer analyzer, IEnumerable <string> paths, bool notify)
            {
                var testCaseData = await analyzer.SendExtensionCommandAsync(
                    TestAnalyzer.Name,
                    TestAnalyzer.GetTestCasesCommand,
                    string.Join(";", paths.Select(PathUtils.NormalizePath).Distinct(StringComparer.OrdinalIgnoreCase))
                    );

                if (testCaseData == null)
                {
                    return;
                }

                var testCaseGroups = TestAnalyzer.GetTestCases(testCaseData).GroupBy(tc => tc.Filename);

                bool anythingToNotify = false;

                foreach (var testCases in testCaseGroups)
                {
                    var path = testCases.Key;
                    if (testCases.Any())
                    {
                        if (!TryGetContainer(path, out TestContainer existing) || !existing.TestCases.SequenceEqual(testCases))
                        {
                            // we have a new entry or some of the tests changed
                            int version = (existing?.Version ?? 0) + 1;
                            lock (_containersLock) {
                                _containers[path] = new TestContainer(
                                    _discoverer,
                                    path,
                                    _project,
                                    version,
                                    Architecture,
                                    testCases.ToArray()
                                    );
                            }

                            anythingToNotify = true;
                        }
                    }
                    else if (RemoveContainer(path))
                    {
                        // Raise containers changed event...
                        anythingToNotify = true;
                    }
                }

                if (notify && anythingToNotify)
                {
                    ContainersChanged();
                }
            }