Пример #1
0
        public void WhenFileIsntAtBackgroundQueueAndTriedToBePromoted_ThenDontDoNothing()
        {
            var now      = DateTime.UtcNow;
            var queue    = new AnalyzerWorkQueue(new LoggerFactory(), utcNow: () => now, timeoutForPendingWorkMs: 10 * 1000);
            var document = CreateTestDocumentId();

            queue.TryPromote(document);

            now = PassOverThrotlingPeriod(now);

            Assert.Empty(queue.TakeWork(AnalyzerWorkType.Foreground));
        }
Пример #2
0
        public void WhenSingleFileIsPromoted_ThenPromoteItFromBackgroundQueueToForeground()
        {
            var now      = DateTime.UtcNow;
            var queue    = new AnalyzerWorkQueue(new LoggerFactory(), utcNow: () => now, timeoutForPendingWorkMs: 10 * 1000);
            var document = CreateTestDocumentId();

            queue.PutWork(new[] { document }, AnalyzerWorkType.Background);

            queue.TryPromote(document);

            now = PassOverThrotlingPeriod(now);

            Assert.NotEmpty(queue.TakeWork(AnalyzerWorkType.Foreground));
        }
        private async Task <ImmutableArray <DocumentDiagnostics> > GetDiagnosticsByDocumentIds(ImmutableArray <DocumentId> documentIds, bool waitForDocuments)
        {
            if (waitForDocuments)
            {
                foreach (var documentId in documentIds)
                {
                    _workQueue.TryPromote(documentId);
                }

                await _workQueue.WaitForegroundWorkComplete();
            }

            return(documentIds
                   .Where(x => _currentDiagnosticResultLookup.ContainsKey(x))
                   .Select(x => _currentDiagnosticResultLookup[x])
                   .ToImmutableArray());
        }