take care of initializing the labels array as late as possible

This commit is contained in:
Brendan Forster
2014-10-12 08:45:57 -03:00
parent bb6187917b
commit 8e594db824
2 changed files with 12 additions and 1 deletions
@@ -41,7 +41,7 @@ public class IssuesLabelsClientTests : IDisposable
Assert.Empty(issueLabelsInfo);
var issueUpdate = new IssueUpdate();
issueUpdate.Labels.Add(label.Name);
issueUpdate.AddLabel(label.Name);
var updated = await _issuesClient.Update(_repositoryOwner, _repository.Name, issue.Number, issueUpdate);
Assert.NotNull(updated);
issueLabelsInfo = await _issuesLabelsClient.GetForIssue(_repositoryOwner, _repositoryName, issue.Number);
+11
View File
@@ -60,5 +60,16 @@ namespace Octokit
return String.Format(CultureInfo.InvariantCulture, "Title: {0}",Title);
}
}
public void AddLabel(string name)
{
// lazily create the label array
if (Labels == null)
{
Labels = new List<string>();
}
Labels.Add(name);
}
}
}