public void Should_Get_Valid_Properties() { // Given var azureDevOpsThread = new AzureDevOpsPullRequestCommentThread( new GitPullRequestCommentThread { Id = 42, Status = CommentThreadStatus.Active, Properties = new PropertiesCollection { { "one", "way" }, { "two", 2 } }, }); // When var prop1 = azureDevOpsThread.GetValue <string>("one"); var prop2 = azureDevOpsThread.GetValue <int>("two"); var prop3 = azureDevOpsThread.GetValue <object>("ghost"); // Then prop1.ShouldNotBeNull(); prop1.ShouldBeOfType <string>(); prop1.ShouldNotBeEmpty(); prop1.ShouldBe("way"); prop2.ShouldNotBeNull(); prop2.ShouldBeOfType <int>(); prop2.ShouldBe(2); prop3.ShouldBeNull(); }
public void Should_Return_Default_Value_If_Property_Collection_Is_Null_For_Integer_Value() { // Given var azureDevOpsThread = new AzureDevOpsPullRequestCommentThread(); // When var result = azureDevOpsThread.GetValue <int>("key"); // Then result.ShouldBe(default(int)); }
public void Should_Throw_If_Property_Name_Is_Empty() { // Given var azureDevOpsThread = new AzureDevOpsPullRequestCommentThread(); // When var result = Record.Exception(() => azureDevOpsThread.GetValue <object>(string.Empty)); // Then result.IsArgumentOutOfRangeException("propertyName"); }
public void Should_Throw_If_Property_Name_Is_Null() { // Given var azureDevOpsThread = new AzureDevOpsPullRequestCommentThread(); // When var result = Record.Exception(() => azureDevOpsThread.GetValue <string>(null)); // Then result.IsArgumentNullException("propertyName"); }
public void Should_Return_Default_Value_If_Property_Does_Not_Exist_For_Int_Value() { // Given var azureDevOpsThread = new AzureDevOpsPullRequestCommentThread( new GitPullRequestCommentThread { Id = 42, Status = CommentThreadStatus.Active, Properties = new PropertiesCollection(), }); // When var result = azureDevOpsThread.GetValue <int>("key"); // Then result.ShouldBe(default(int)); }
/// <summary> /// Gets the comment identifier to identify the issue for which the comment was created. /// </summary> /// <param name="thread">Thread to get the value from.</param> /// <returns>Comment identifier value.</returns> public static string GetCommentIdentifier(this AzureDevOpsPullRequestCommentThread thread) { thread.NotNull(nameof(thread)); return(thread.GetValue <string>(CommentIdentifierPropertyName)); }
/// <summary> /// Gets the provider type value used to identify specific provider origins later on when reading back existing issues. /// </summary> /// <param name="thread">Thread to get the value from.</param> /// <returns>Comment source value.</returns> public static string GetProviderType(this AzureDevOpsPullRequestCommentThread thread) { thread.NotNull(nameof(thread)); return(thread.GetValue <string>(ProviderTypePropertyName)); }
/// <summary> /// Gets the original message of the issue as provided by Cake.Issues.PullRequests, /// without any formatting done by this addin. /// </summary> /// <param name="thread">Thread to get the value from.</param> /// <returns>Original message of the issue.</returns> public static string GetIssueMessage(this AzureDevOpsPullRequestCommentThread thread) { thread.NotNull(nameof(thread)); return(thread.GetValue <string>(IssueMessagePropertyName)); }