Skip to content
Open
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
16 changes: 14 additions & 2 deletions SySML2.NET.REST.Tests/PsmApiClientTestFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -374,15 +374,27 @@ await Assert.ThatAsync(() => this.client.PutProjectByIdAsync(ProjectId, projectR
public async Task VerifyMergeAsync()
{
var mergeUri = $"{BaseAddress}projects/{ProjectId}/branches/{BranchId}/merge";
string mergeBody = null;

this.mockHttp.Expect(HttpMethod.Post, mergeUri)
.WithExactQueryString($"sourceCommitId={CommitId},{OtherCommitId}&description=the%20merge%20description")
.With(request => request.Content.ReadAsStringAsync().GetAwaiter().GetResult().Contains(RootNamespaceId.ToString()))
.With(request =>
{
mergeBody = request.Content.ReadAsStringAsync().GetAwaiter().GetResult();
return true;
})
.Respond(HttpStatusCode.Created, JsonMediaType, ReadPayload("commit.json"));

var mergeCommit = await this.client.MergeAsync(ProjectId, [CommitId, OtherCommitId], BranchId, [new Namespace { Id = RootNamespaceId }], "the merge description");

Assert.That(mergeCommit.Id, Is.EqualTo(CommitId));
using (Assert.EnterMultipleScope())
{
Assert.That(mergeCommit.Id, Is.EqualTo(CommitId));
Assert.That(mergeBody, Does.Contain(RootNamespaceId.ToString()));
Assert.That(mergeBody, Does.Contain("\"qualifiedName\""));
Assert.That(mergeBody, Does.Contain("\"owner\""));
Assert.That(mergeBody, Does.Contain("\"membership\""));
}

await Assert.ThatAsync(() => this.client.MergeAsync(ProjectId, null, BranchId), Throws.TypeOf<ArgumentNullException>());

Expand Down
4 changes: 2 additions & 2 deletions SySML2.NET.REST/PsmApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ private async Task<HttpContent> CreateContentAsync(IRequest requestBody, Cancell
}

/// <summary>
/// Creates the JSON body of a request from a sequence of data items
/// Creates the JSON body of a request from a sequence of data items, each written as a full <c>Data</c> including its derived properties
/// </summary>
/// <param name="requestBody">
/// The <see cref="IData"/> items to send, or <c>null</c> to send no body
Expand All @@ -327,7 +327,7 @@ private async Task<HttpContent> CreateContentAsync(IEnumerable<IData> requestBod

var stream = new MemoryStream();

await this.serializer.SerializeAsync(requestBody, SerializationModeKind.JSON, false, stream, WriterOptions, cancellationToken);
await this.serializer.SerializeAsync(requestBody, SerializationModeKind.JSON, true, stream, WriterOptions, cancellationToken);

return CreateContent(stream);
}
Expand Down
Loading