public GitHubPullRequestFile(string fileName, GitHubPullRequestFileStatus status, int changes, string diff) { if (fileName == null) { throw new ArgumentNullException("fileName"); } if (diff == null) { throw new ArgumentNullException("diff"); } const string cannotBeEmptyMessage = "Cannot be empty"; if (fileName.Length == 0) { throw new ArgumentException(cannotBeEmptyMessage, "fileName"); } if (diff.Length == 0) { throw new ArgumentException(cannotBeEmptyMessage, "diff"); } this.FileName = fileName; this.Status = status; this.Changes = changes; this.Diff = diff; }
/// <summary> /// Gets a <see cref="PullRequestCommenter"/>. /// </summary> /// <param name="status">The target <see cref="GitHubPullRequestFileStatus"/> of file to comment on.</param> /// <returns>A <see cref="PullRequestCommenter"/>.</returns> public PullRequestCommenter GetCommenter(GitHubPullRequestFileStatus status) { PullRequestCommenter commenter; switch (status) { case GitHubPullRequestFileStatus.Added: commenter = new AddedPullRequestCommenter(this.client, this.repository); break; case GitHubPullRequestFileStatus.Removed: commenter = PullRequestCommenter.NoComment; break; case GitHubPullRequestFileStatus.Modified: if (this.DiffRetriever == null) { throw new InvalidOperationException("DiffRetriever is null"); } commenter = new ModifiedPullRequestCommenter(this.client, this.repository, this.DiffRetriever); break; case GitHubPullRequestFileStatus.Renamed: commenter = new RenamedPullRequestCommenter(this.client, this.repository); break; default: throw new ArgumentException( string.Format(CultureInfo.InvariantCulture, "Unknown status: {0}", status), "status"); } return commenter; }
public static void GetCommenterShouldReturnPullRequestCommenterObject(GitHubPullRequestFileStatus status, Type expectedType) { var factory = GetPullRequestCommenterFactory(); var commenter = factory.GetCommenter(status); Assert.That(commenter, Is.InstanceOf(expectedType)); }