/// <summary> /// This method wait for a few seconds till <param name="cloneWindowViewModel"/> IsReady is true; /// </summary> private async Task WaitForBackgroundAsyncTask(CsrCloneWindowViewModel cloneWindowViewModel) { Stopwatch watch = Stopwatch.StartNew(); while (!cloneWindowViewModel.IsReady && watch.Elapsed < TimeSpan.FromSeconds(1)) { await Task.Delay(10); } Assert.IsTrue(cloneWindowViewModel.IsReady); }
public void Initialize() { _apiManagerMock = new Mock <IApiManager>(); _testProjectMock = new Mock <Project>(); _testProjectMock.SetupGet(x => x.ProjectId).Returns("test_project_id"); _testProjects = new List <Project> { new Mock <Project>().Object, _testProjectMock.Object }; _getCloudReposMock = new Mock <Func <string, Task <IList <Repo> > > >(); _testTaskCompletionSource = new TaskCompletionSource <IList <Repo> >(); _getCloudReposMock.Setup(f => f(It.IsAny <string>())).Returns(() => { var task = _testTaskCompletionSource.Task; // Reset it to make it easier to call and set multiple times. _testTaskCompletionSource = new TaskCompletionSource <IList <Repo> >(); return(task); }); CsrCloneWindowViewModel.s_getCloudReposAsync = _getCloudReposMock.Object; CsrCloneWindowViewModel.s_getApiManagerFunc = projectId => _apiManagerMock.Object; _closeWindowActionMock = new Mock <Action>(); _cloneWindowViewModel = new CsrCloneWindowViewModel(_closeWindowActionMock.Object, _testProjects); }