예제 #1
0
        public async Task TestEditZoneAsync()
        {
            var zone     = ZoneTestData.Zones.First();
            var modified = new ModifiedZone {
                Paused = true
            };

            _wireMockServer
            .Given(Request.Create().WithPath($"/{ZoneEndpoints.Base}/{zone.Id}").UsingPatch())
            .RespondWith(Response.Create().WithStatusCode(200)
                         .WithBody(x =>
            {
                var body     = JsonConvert.DeserializeObject <ModifiedZone>(x.Body);
                var response = ZoneTestData.Zones.First(y => y.Id == x.PathSegments[1]).DeepClone();

                if (body.Paused != null)
                {
                    response.Paused = body.Paused.Value;
                }

                return(WireMockResponseHelper.CreateTestResponse(response));
            }));

            using var client = new CloudFlareClient(WireMockConnection.ApiKeyAuthentication, _connectionInfo);

            var editZone = await client.Zones.UpdateAsync(zone.Id, modified);

            editZone.Result.Should().BeEquivalentTo(zone, opt => opt.Excluding(y => y.Paused));
            editZone.Result.Paused.Should().BeTrue();
        }
예제 #2
0
        public void TestSerialization()
        {
            var sut = new ModifiedZone();

            JsonHelper.GetSerializedKeys(sut).Should().BeEquivalentTo(new SortedSet <string> {
                "vanity_name_servers", "paused", "plan"
            });
        }
예제 #3
0
        /// <inheritdoc />
        public async Task <CloudFlareResult <Zone> > UpdateAsync(string zoneId, ModifiedZone modifiedZone, CancellationToken cancellationToken = default)
        {
            var requestUri = $"{ZoneEndpoints.Base}/{zoneId}";

            return(await Connection.PatchAsync <Zone, ModifiedZone>(requestUri, modifiedZone, cancellationToken).ConfigureAwait(false));
        }