/// <summary> /// Converts the reference to a string using the specified format /// </summary> public string ToString(GitLabReferenceFormat format) { var stringBuilder = new StringBuilder(); if (format == GitLabReferenceFormat.Full) { stringBuilder.Append(Project.ProjectPath); } else if (format == GitLabReferenceFormat.ProjectAndItem) { stringBuilder.Append(Project.Project); } stringBuilder.Append(Type switch { GitLabReferenceType.Issue => "#", GitLabReferenceType.MergeRequest => "!", GitLabReferenceType.Milestone => "%", _ => throw new NotImplementedException() });
public void ToString_returns_expected_value_when_format_is_specified(string @namespace, string project, GitLabReferenceType type, int id, GitLabReferenceFormat format, string expected) { // ARRANGE var sut = new GitLabReference(new("example.com", @namespace, project), type, id); // ACT var actual = sut.ToString(format); // ASSERT Assert.Equal(expected, actual); }