public void Should_Throw_If_Comment_Is_Whitespace() { // Given var fixture = new PullRequestFixture(BasePullRequestFixture.ValidAzureDevOpsServerUrl, 100); var pullRequest = new AzureDevOpsPullRequest(fixture.Log, fixture.Settings, fixture.GitClientFactory); // When var result = Record.Exception(() => pullRequest.CreateComment(" ")); // Then result.IsArgumentOutOfRangeException("comment"); }
public void Should_Throw_If_Comment_Is_Null_Or_Empty_Or_Whitespace(string comment, Type expectedExceptionType) { // Given var fixture = new PullRequestFixture(BasePullRequestFixture.ValidAzureDevOpsServerUrl, 100); var pullRequest = new AzureDevOpsPullRequest(fixture.Log, fixture.Settings, fixture.GitClientFactory); // When var result = Record.Exception(() => pullRequest.CreateComment(comment)) as ArgumentException; // Then result.ShouldNotBeNull(); result.IsArgumentException(expectedExceptionType, "comment"); }
public void Should_Not_Throw_If_Null_Is_Returned() { // Given var fixture = new PullRequestFixture(BasePullRequestFixture.ValidAzureDevOpsServerUrl, 100) { GitClientFactory = new FakeNullForMethodsGitClientFactory(), }; var pullRequest = new AzureDevOpsPullRequest(fixture.Log, fixture.Settings, fixture.GitClientFactory); // When pullRequest.CreateComment("Foo"); // Then // ?? Nothing to validate here since the method returns void }
public void Should_Return_Null_If_Null_Is_Returned_From_Git_Client() { // Given var fixture = new PullRequestFixture(BasePullRequestFixture.ValidAzureDevOpsServerUrl, 100) { GitClientFactory = new FakeNullForMethodsGitClientFactory(), }; var pullRequest = new AzureDevOpsPullRequest(fixture.Log, fixture.Settings, fixture.GitClientFactory); // When var thread = pullRequest.CreateComment("Foo"); // Then thread.ShouldBeNull(); }
public void Should_Create_Valid_Thread_With_One_Comment() { // Given var fixture = new PullRequestFixture(BasePullRequestFixture.ValidAzureDevOpsServerUrl, 100); var pullRequest = new AzureDevOpsPullRequest(fixture.Log, fixture.Settings, fixture.GitClientFactory); // When var thread = pullRequest.CreateComment("Valid"); // Then thread.ShouldNotBeNull(); thread.Status.ShouldBe(AzureDevOpsCommentThreadStatus.Active); thread.Comments.ShouldNotBeNull(); thread.Comments.Count().ShouldBe(1); var comment = thread.Comments.First(); comment.CommentType.ShouldBe(AzureDevOpsCommentType.System); comment.IsDeleted.ShouldBeFalse(); comment.Content.ShouldBe("Valid"); }