private void SetupAnalyzer() { _analyzerMock = new Mock <IReferenceAnalyzer>(); var referencedProjects = new List <ActualReference> { new("project1", Enumerable.Empty <ReferenceOccurrence>()) }; _project1 = new Project("proj1", "path1"); _project2 = new Project("proj2", "path2"); _analyzerMock.Setup(m => m.Load(It.IsAny <string>(), It.IsAny <CancellationToken>())) .Returns(Task.FromResult(new[] { _project1, _project2 }.AsEnumerable())); var firstReport = new ReferencesReport(new[] { new Reference("ref1"), new Reference("ref2") }, referencedProjects); var secondReport = new ReferencesReport(new[] { new Reference("ref2"), new Reference("ref3") }, Enumerable.Empty <ActualReference>()); _reports = new[] { new Analysis(_project1, Observable.Return(firstReport)), new Analysis(_project2, Observable.Return(secondReport)) }; _analyzerMock.Setup(m => m.Analyze(_project1, It.IsAny <CancellationToken>())) .Returns(Task.FromResult(firstReport)); _analyzerMock.Setup(m => m.Analyze(_project2, It.IsAny <CancellationToken>())) .Returns(Task.FromResult(secondReport)); _analyzerMock.Setup(m => m.Analyze(It.IsAny <IEnumerable <Project> >(), It.IsAny <CancellationToken>())) .Returns(_reports.ToObservable()); _analyzerMock.Setup(m => m.Load("error_project", It.IsAny <CancellationToken>())) .Throws <InvalidOperationException>(); }
private void ExportReferenceFavorite(ReferenceFavoriteViewModel favorite) { if (favorite == null) { return; } var plugin = PluginManager.Instance.GetPluginByName("Tools"); var refIds = new List <Int32>(); GetFavoriteRefIds(favorite, refIds); if (refIds.Count == 0) { return; } var report = new ReferencesReport(User, favorite.DisplayLabel, refIds); PluginManager.Instance.RunReport(plugin, report); }
public void WhenIRunAnalysis(string target) => _result = _sut.Analyze(new Project(target, "anyPath"), CancellationToken.None).Result;