public async Task EvaluateAsync(GitPullRequest pullRequest, GitStatusState expectedState) { pullRequest.PullRequestId = 5; pullRequest.Status = PullRequestStatus.Active; pullRequest.Repository = new GitRepository { Id = Guid.NewGuid() }; _connectionFactoryMock.Setup(c => c.GetClientAsync <GitHttpClient>()).ReturnsAsync(_gitClientMock.Object); var statusPolicy = Activator.CreateInstance(typeof(T), _connectionFactoryMock.Object) as StatusPolicy; await statusPolicy.EvaluateAsync(pullRequest); _gitClientMock.Verify(m => m.CreatePullRequestStatusAsync(It.Is <GitPullRequestStatus>(p => p.State == expectedState && p.Context.Name == typeof(T).Name.Replace("StatusPolicy", string.Empty).ToKebabCase()), pullRequest.Repository.Id, pullRequest.PullRequestId, It.IsAny <object>(), It.IsAny <CancellationToken>()), Times.Once); }
protected async Task UpdateStatusAsync(GitStatusState state, string description) { var client = await ServiceFactory.GetClientAsync <GitHttpClient>(); var status = new GitPullRequestStatus { State = state, Description = description, TargetUrl = TargetUrl, Context = new GitStatusContext { Genre = "ait-policy", Name = GetName() } }; await client.CreatePullRequestStatusAsync(status, PullRequest.Repository.Id, PullRequest.PullRequestId); }