private void AndPendingUpdates(Build forBuild) { AfterDbUpdateActions.Add( () => { var updates = new List <PullRequestActorImplementation.UpdateAssetsParameters> { new PullRequestActorImplementation.UpdateAssetsParameters { SubscriptionId = Subscription.Id, BuildId = forBuild.Id, SourceRepo = forBuild.GitHubRepository ?? forBuild.AzureDevOpsRepository, SourceSha = forBuild.Commit, Assets = forBuild.Assets .Select(a => new Asset { Name = a.Name, Version = a.Version }) .ToList(), IsCoherencyUpdate = false } }; StateManager.Data[PullRequestActorImplementation.PullRequestUpdate] = updates; ExpectedActorState[PullRequestActorImplementation.PullRequestUpdate] = updates; }); }
private IDisposable WithExistingPullRequest(SynchronizePullRequestResult checkResult) { AfterDbUpdateActions.Add(() => { var pr = new InProgressPullRequest { Url = InProgressPrUrl, ContainedSubscriptions = new List <SubscriptionPullRequestUpdate> { new SubscriptionPullRequestUpdate { BuildId = -1, SubscriptionId = Subscription.Id } }, RequiredUpdates = new List <DependencyUpdateSummary> { new DependencyUpdateSummary { DependencyName = "Ham", FromVersion = "1.0.0-beta.1", ToVersion = "1.0.1-beta.1" }, new DependencyUpdateSummary { DependencyName = "Ham", FromVersion = "1.0.0-beta.1", ToVersion = "1.0.1-beta.1" }, } }; StateManager.SetStateAsync(PullRequestActorImplementation.PullRequest, pr); ExpectedActorState.Add(PullRequestActorImplementation.PullRequest, pr); }); ActionRunner.Setup(r => r.ExecuteAction(It.IsAny <Expression <Func <Task <ActionResult <SynchronizePullRequestResult> > > > >())) .ReturnsAsync(checkResult); if (checkResult == SynchronizePullRequestResult.InProgressCanUpdate) { DarcRemotes.GetOrAddValue(TargetRepo, CreateMock <IRemote>) .Setup(r => r.GetPullRequestAsync(InProgressPrUrl)) .ReturnsAsync( new PullRequest { HeadBranch = InProgressPrHeadBranch, BaseBranch = TargetBranch }); } return(Disposable.Create( () => { ActionRunner.Verify(r => r.ExecuteAction(It.IsAny <Expression <Func <Task <ActionResult <SynchronizePullRequestResult> > > > >())); if (checkResult == SynchronizePullRequestResult.InProgressCanUpdate) { DarcRemotes[TargetRepo].Verify(r => r.GetPullRequestAsync(InProgressPrUrl)); } })); }