Beispiel #1
0
        public async Task TestMergeResult()
        {
            Mock.Expect(HttpMethods.Patch, "http://localhost/endpoint")
            .WithContent("{\"id\":5,\"name\":\"test\"}")
            .Respond(JsonMime, "{\"id\":5,\"name\":\"testXXX\"}");

            var result = await _endpoint.MergeAsync(new MockEntity(5, "test"));

            result.Should().Be(new MockEntity(5, "testXXX"));
        }
Beispiel #2
0
        /// <summary>
        /// Modifies existing <see cref="RecordSet"/>s.
        /// </summary>
        /// <remarks><see cref="RecordSet.ChangeType"/> must be set accordingly.</remarks>
        /// <exception cref="ArgumentNullException">If <see cref="RecordSet.ChangeType"/> is not set.</exception>
        /// <exception cref="InvalidDataException"><see cref="HttpStatusCode.BadRequest" /></exception>
        /// <exception cref="AuthenticationException"><see cref="HttpStatusCode.Unauthorized" /></exception>
        /// <exception cref="UnauthorizedAccessException"><see cref="HttpStatusCode.Forbidden" /></exception>
        /// <exception cref="KeyNotFoundException"><see cref="HttpStatusCode.NotFound" /> or <see cref="HttpStatusCode.Gone" /></exception>
        /// <exception cref="HttpRequestException">Other non-success status code.</exception>
        public static Task PatchRecordSetAsync(this IElementEndpoint <Zone> endpoint,
                                               RecordSet recordSet,
                                               CancellationToken cancellationToken = default)
        {
            if (!recordSet.ChangeType.HasValue)
            {
                throw new ArgumentException($"{nameof(ChangeType)} must be set.", nameof(recordSet));
            }

            string zoneName = endpoint.Uri.AbsolutePath.Split('/').Last();

            return(endpoint.MergeAsync(new Zone(zoneName)
            {
                RecordSets = { recordSet }
            }, cancellationToken));
        }