Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NGitLab.Mock/Clients/IssueClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public Models.Issue Create(IssueCreate issueCreate)
Description = issueCreate.Description,
Title = issueCreate.Title,
Author = Context.User,
Confidential = issueCreate.Confidential,
};

if (!string.IsNullOrEmpty(issueCreate.Labels))
Expand Down
73 changes: 63 additions & 10 deletions NGitLab.Mock/Clients/ProjectIssueNoteClient.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;

using NGitLab.Models;

namespace NGitLab.Mock.Clients
Expand All @@ -14,24 +15,76 @@ public ProjectIssueNoteClient(ClientContext context, int projectId)
_projectId = projectId;
}

public ProjectIssueNote Create(ProjectIssueNoteCreate create)
public Models.ProjectIssueNote Create(ProjectIssueNoteCreate create)
{
using (Context.BeginOperationScope())
{
var issue = GetIssue(create.IssueId);

var projectIssueNote = new ProjectIssueNote
{
Body = create.Body,
Confidential = create.Confidential,
Author = Context.User,
};
issue.Notes.Add(projectIssueNote);

return projectIssueNote.ToProjectIssueNote();
}
}

public Models.ProjectIssueNote Edit(ProjectIssueNoteEdit edit)
{
throw new NotImplementedException();
using (Context.BeginOperationScope())
{
var note = GetIssueNote(edit.IssueId, edit.NoteId);

note.Body = edit.Body;

return note.ToProjectIssueNote();
}
}

public ProjectIssueNote Edit(ProjectIssueNoteEdit edit)
public IEnumerable<Models.ProjectIssueNote> ForIssue(int issueId)
{
throw new NotImplementedException();
using (Context.BeginOperationScope())
{
return GetIssue(issueId).Notes.Select(n => n.ToProjectIssueNote());
}
}

public IEnumerable<ProjectIssueNote> ForIssue(int issueId)
public Models.ProjectIssueNote Get(int issueId, int noteId)
{
throw new NotImplementedException();
using (Context.BeginOperationScope())
{
return GetIssueNote(issueId, noteId).ToProjectIssueNote();
}
}

public ProjectIssueNote Get(int issueId, int noteId)
private Issue GetIssue(int issueId)
{
throw new NotImplementedException();
var project = GetProject(_projectId, ProjectPermission.Contribute);
var issue = project.Issues.FirstOrDefault(iss => iss.Id == issueId);

if (issue == null)
{
throw new GitLabNotFoundException("Issue does not exist.");
}

return issue;
}

private ProjectIssueNote GetIssueNote(int issueId, int issueNoteId)
{
var issue = GetIssue(issueId);
var note = issue.Notes.FirstOrDefault(n => (int)n.Id == issueNoteId);

if (note == null)
{
throw new GitLabNotFoundException("Issue Note does not exist.");
}

return note;
}
}
}
6 changes: 6 additions & 0 deletions NGitLab.Mock/Issue.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;

Expand Down Expand Up @@ -38,6 +39,10 @@ public UserRef Assignee

public DateTimeOffset? ClosedAt { get; set; }

public bool Confidential { get; set; }

public IList<ProjectIssueNote> Notes { get; set; }

public string WebUrl => Server.MakeUrl($"{Project.PathWithNamespace}/-/issues/{Iid.ToString(CultureInfo.InvariantCulture)}");

public IssueState State
Expand Down Expand Up @@ -87,6 +92,7 @@ public Models.Issue ToClientIssue()
CreatedAt = CreatedAt.UtcDateTime,
UpdatedAt = UpdatedAt.UtcDateTime,
WebUrl = WebUrl,
Confidential = Confidential,
};
}
}
Expand Down
3 changes: 3 additions & 0 deletions NGitLab.Mock/Note.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ protected Note()

public bool Resolved { get; set; }

public bool Confidential { get; set; }

public Models.Note ToClientEvent()
{
return new Models.Note
Expand All @@ -46,6 +48,7 @@ public Models.Note ToClientEvent()
System = System,
Resolved = Resolved,
UpdatedAt = UpdatedAt.UtcDateTime,
Confidential = Confidential,
};
}
}
Expand Down
28 changes: 28 additions & 0 deletions NGitLab.Mock/ProjectIssueNote.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace NGitLab.Mock
{
public sealed class ProjectIssueNote : Note
{
public new Issue Parent => (Issue)base.Parent;

public override string NoteableType => "Issue";

public override int NoticableId => Parent.Id;

public override int NoticableIid => Parent.Iid;

internal Models.ProjectIssueNote ToProjectIssueNote()
{
return new Models.ProjectIssueNote
{
NoteId = (int)Id,
Body = Body,
Author = Author.ToClientAuthor(),
CreatedAt = CreatedAt.UtcDateTime,
UpdatedAt = UpdatedAt.UtcDateTime,
System = System,
Resolvable = Resolvable,
Confidential = Confidential,
};
}
}
}
12 changes: 12 additions & 0 deletions NGitLab.Mock/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,8 @@ NGitLab.Mock.Issue.Author.get -> NGitLab.Mock.UserRef
NGitLab.Mock.Issue.Author.set -> void
NGitLab.Mock.Issue.ClosedAt.get -> System.DateTimeOffset?
NGitLab.Mock.Issue.ClosedAt.set -> void
NGitLab.Mock.Issue.Confidential.get -> bool
NGitLab.Mock.Issue.Confidential.set -> void
NGitLab.Mock.Issue.CreatedAt.get -> System.DateTimeOffset
NGitLab.Mock.Issue.Description.get -> string
NGitLab.Mock.Issue.Description.set -> void
Expand All @@ -403,6 +405,8 @@ NGitLab.Mock.Issue.Labels.get -> string[]
NGitLab.Mock.Issue.Labels.set -> void
NGitLab.Mock.Issue.Milestone.get -> NGitLab.Mock.Milestone
NGitLab.Mock.Issue.Milestone.set -> void
NGitLab.Mock.Issue.Notes.get -> System.Collections.Generic.IList<NGitLab.Mock.ProjectIssueNote>
NGitLab.Mock.Issue.Notes.set -> void
NGitLab.Mock.Issue.Project.get -> NGitLab.Mock.Project
NGitLab.Mock.Issue.ProjectId.get -> int
NGitLab.Mock.Issue.State.get -> NGitLab.Mock.IssueState
Expand Down Expand Up @@ -580,6 +584,8 @@ NGitLab.Mock.Note.Author.get -> NGitLab.Mock.UserRef
NGitLab.Mock.Note.Author.set -> void
NGitLab.Mock.Note.Body.get -> string
NGitLab.Mock.Note.Body.set -> void
NGitLab.Mock.Note.Confidential.get -> bool
NGitLab.Mock.Note.Confidential.set -> void
NGitLab.Mock.Note.CreatedAt.get -> System.DateTimeOffset
NGitLab.Mock.Note.CreatedAt.set -> void
NGitLab.Mock.Note.Id.get -> long
Expand Down Expand Up @@ -753,6 +759,9 @@ NGitLab.Mock.ProjectHook.WikiPagesEvents.get -> bool
NGitLab.Mock.ProjectHook.WikiPagesEvents.set -> void
NGitLab.Mock.ProjectHookCollection
NGitLab.Mock.ProjectHookCollection.ProjectHookCollection(NGitLab.Mock.GitLabObject container) -> void
NGitLab.Mock.ProjectIssueNote
NGitLab.Mock.ProjectIssueNote.ProjectIssueNote() -> void
NGitLab.Mock.ProjectIssueNote.Parent.get -> NGitLab.Mock.Issue
NGitLab.Mock.ReleaseCollection
NGitLab.Mock.ReleaseCollection.Add(string tagName, string name, string description, NGitLab.Mock.User user) -> NGitLab.Mock.ReleaseInfo
NGitLab.Mock.ReleaseCollection.Add(string tagName, string name, string reference, string description, NGitLab.Mock.User user) -> NGitLab.Mock.ReleaseInfo
Expand Down Expand Up @@ -949,6 +958,9 @@ override NGitLab.Mock.NoteCollection<T>.Add(T item) -> void
override NGitLab.Mock.PipelineCollection.Add(NGitLab.Mock.Pipeline pipeline) -> void
override NGitLab.Mock.ProjectCollection.Add(NGitLab.Mock.Project project) -> void
override NGitLab.Mock.ProjectHookCollection.Add(NGitLab.Mock.ProjectHook item) -> void
override NGitLab.Mock.ProjectIssueNote.NoteableType.get -> string
override NGitLab.Mock.ProjectIssueNote.NoticableId.get -> int
override NGitLab.Mock.ProjectIssueNote.NoticableIid.get -> int
override NGitLab.Mock.ReleaseCollection.Add(NGitLab.Mock.ReleaseInfo release) -> void
override NGitLab.Mock.RunnerCollection.Add(NGitLab.Mock.Runner item) -> void
override NGitLab.Mock.RunnerRef.Equals(object obj) -> bool
Expand Down
3 changes: 3 additions & 0 deletions NGitLab/Models/Issue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,8 @@ public class Issue

[DataMember(Name = "epic")]
public IssueEpic Epic;

[DataMember(Name = "confidential")]
public bool Confidential;
}
}
3 changes: 3 additions & 0 deletions NGitLab/Models/IssueCreate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@ public class IssueCreate

[DataMember(Name = "labels")]
public string Labels;

[DataMember(Name = "confidential")]
public bool Confidential;
}
}
3 changes: 3 additions & 0 deletions NGitLab/Models/Note.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@ public class Note

[DataMember(Name = "system")]
public bool System;

[DataMember(Name = "confidential")]
public bool Confidential;
}
}
3 changes: 3 additions & 0 deletions NGitLab/Models/ProjectIssueNote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,8 @@ public class ProjectIssueNote

[DataMember(Name = "resolvable")]
public bool Resolvable;

[DataMember(Name = "confidential")]
public bool Confidential;
}
}
3 changes: 3 additions & 0 deletions NGitLab/Models/ProjectIssueNoteCreate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ public class ProjectIssueNoteCreate
[Required]
[DataMember(Name = "body")]
public string Body;

[DataMember(Name = "confidential")]
public bool Confidential;
}
}
5 changes: 5 additions & 0 deletions NGitLab/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1467,6 +1467,7 @@ NGitLab.Models.Issue
NGitLab.Models.Issue.Assignee -> NGitLab.Models.Assignee
NGitLab.Models.Issue.Assignees -> NGitLab.Models.Assignee[]
NGitLab.Models.Issue.Author -> NGitLab.Models.Author
NGitLab.Models.Issue.Confidential -> bool
NGitLab.Models.Issue.CreatedAt -> System.DateTime
NGitLab.Models.Issue.Description -> string
NGitLab.Models.Issue.DueDate -> System.DateTime?
Expand All @@ -1485,6 +1486,7 @@ NGitLab.Models.Issue.UpdatedAt -> System.DateTime
NGitLab.Models.Issue.WebUrl -> string
NGitLab.Models.IssueCreate
NGitLab.Models.IssueCreate.AssigneeId -> int?
NGitLab.Models.IssueCreate.Confidential -> bool
NGitLab.Models.IssueCreate.Description -> string
NGitLab.Models.IssueCreate.Id -> int
NGitLab.Models.IssueCreate.IssueCreate() -> void
Expand Down Expand Up @@ -1937,6 +1939,7 @@ NGitLab.Models.Note
NGitLab.Models.Note.Author.get -> NGitLab.Models.User
NGitLab.Models.Note.Author.set -> void
NGitLab.Models.Note.Body -> string
NGitLab.Models.Note.Confidential -> bool
NGitLab.Models.Note.CreatedAt -> System.DateTime
NGitLab.Models.Note.Id -> long
NGitLab.Models.Note.Note() -> void
Expand Down Expand Up @@ -2165,6 +2168,7 @@ NGitLab.Models.ProjectIssueNote
NGitLab.Models.ProjectIssueNote.Attachment -> string
NGitLab.Models.ProjectIssueNote.Author -> NGitLab.Models.Author
NGitLab.Models.ProjectIssueNote.Body -> string
NGitLab.Models.ProjectIssueNote.Confidential -> bool
NGitLab.Models.ProjectIssueNote.CreatedAt -> System.DateTime
NGitLab.Models.ProjectIssueNote.NoteableId -> int
NGitLab.Models.ProjectIssueNote.NoteableType -> string
Expand All @@ -2176,6 +2180,7 @@ NGitLab.Models.ProjectIssueNote.System -> bool
NGitLab.Models.ProjectIssueNote.UpdatedAt -> System.DateTime
NGitLab.Models.ProjectIssueNoteCreate
NGitLab.Models.ProjectIssueNoteCreate.Body -> string
NGitLab.Models.ProjectIssueNoteCreate.Confidential -> bool
NGitLab.Models.ProjectIssueNoteCreate.IssueId -> int
NGitLab.Models.ProjectIssueNoteCreate.ProjectIssueNoteCreate() -> void
NGitLab.Models.ProjectIssueNoteEdit
Expand Down