public async Task DoUpdate_CallsProjectsUpdate() { var projectSettingses = new[] { _aMonitoredProjectSettings }; _monitorSettings.Projects.Returns(projectSettingses); var tfProject = Substitute.For <ITfProject>(); var tfsServer = Substitute.For <ITfProjectCollection>(); tfsServer.GetProject(_aMonitoredProjectSettings.Id).Returns(tfProject); _tfProjectCollectionCache.GetProjectCollection(Arg.Any <string>()).Returns(tfsServer); var systemUnderTest = new Monitor(_monitorSettings, _tfProjectCollectionCache, _nameRegexpRepositoryFilterFactory, _logger); await systemUnderTest.DoUpdate(projectSettingses); #pragma warning disable 4014 tfProject.Received().RetrievePullRequests(); #pragma warning restore 4014 }
private void SetTeamProjectCollection() { if (_teamProjectCollection != null) { _teamProjectCollection.ProjectRetrievalCompleted -= OnProjectRetrievalCompleted; } _teamProjectCollection = _projectCollectionCache.GetProjectCollection(_model.VstsAccount); _teamProjectCollection.ProjectRetrievalCompleted += OnProjectRetrievalCompleted; RefreshProjects(); OnPropertyChanged(nameof(IsRefreshingProjects)); OnPropertyChanged(nameof(HasProjects)); OnPropertyChanged(nameof(HasSelectedProject)); }
public async Task <MonitorStatus> SyncMonitoredProjects(IEnumerable <MonitoredProjectSettings> monitoredProjectSettings) { foreach (var projectSettings in monitoredProjectSettings) { var projectCollection = _tfProjectCollectionCache.GetProjectCollection(projectSettings.VstsAccount); if (projectCollection.ProjectRetrievalStatus != RetrievalStatus.Suceeded) { await projectCollection.RetrieveProjects(); } switch (projectCollection.ProjectRetrievalStatus) { case RetrievalStatus.FailedDueToConnection: return(MonitorStatus.CouldNotReachServer); case RetrievalStatus.FailedDueToAuth: return(MonitorStatus.AuthorisationError); case RetrievalStatus.FailedReasonUnknown: return(MonitorStatus.UnrecognisedError); } if (!_projects.ContainsKey(projectSettings.Id)) { _projects[projectSettings.Id] = projectCollection.GetProject(projectSettings.Id); } if (!string.IsNullOrEmpty(projectSettings.RepoNameRegexp)) { _projects[projectSettings.Id].RepositoryFilter = _nameRegexpRepositoryFilterFactory.Create(projectSettings.RepoNameRegexp); } } foreach (var removedProject in _projects.Keys.Where(id => monitoredProjectSettings.Count(s => s.Id == id) == 0)) { ITfProject project; _projects.TryRemove(removedProject, out project); } return(MonitorStatus.UpdateSuccessful); }