Beispiel #1
0
        public async Task AddService(KongService service)
        {
            var content  = service.ToJsonStringContent();
            var response = await HttpClient.PostAsync("/services/", content);

            var responseBody = await response.Content.ReadAsStringAsync();

            var added = JsonConvert.DeserializeObject <KongService>(responseBody);

            service.Id = added.Id;
        }
        public async Task UpdateService(KongService service)
        {
            Log.Information("Updating service {name}", service.Name);
            var content = service.ToJsonStringContent();

            try
            {
                await HttpClient.PatchAsync($"/services/{service.Id}", content);
            }
            catch (Exception e)
            {
                Log.Error(e, e.Message);
                throw;
            }
        }
        public async Task AddService(KongService service)
        {
            Log.Information($"Adding service {service.Name}");
            var content = service.ToJsonStringContent();

            try
            {
                var response = await HttpClient.PostAsync("/services/", content);

                var responseBody = await response.Content.ReadAsStringAsync();

                var added = JsonConvert.DeserializeObject <KongService>(responseBody);
                service.Id = added.Id;
            }
            catch (Exception e)
            {
                Log.Error(e, e.Message);
                throw;
            }
        }
        public void Scenario3()
        {
            KongService service = null;

            this.Given(() => service = Fixture.Create <KongService>(), "A kong service")
            .And(s => s.KongRespondsCorrectly <KongService>(HttpMethod.Put, $"/services/{service.Id}", service.ToJsonStringContent()),
                 KongRespondsCorrectlyToMethodAtPathTextTemplate)
            .When(async() => await Subject.PutService(service), Invoking(nameof(KongAdminWriter.PutService)))
            .Then("it succeeds")
            .BDDfy();
        }
        public void Scenario2()
        {
            KongService service = null;

            this.Given(() => service = Fixture.Create <KongService>(), "An existing kong service")
            .And(s => s.KongRespondsCorrectly <KongService>(new HttpMethod("PATCH"), $"/services/{service.Id}", service.ToJsonStringContent(), x => x.WithIdAndCreatedAt()),
                 KongRespondsCorrectlyToMethodAtPathTextTemplate)
            .When(async() => await Subject.UpdateService(service), Invoking(nameof(KongAdminWriter.UpdateService)))
            .Then("it succeeds")
            .BDDfy();
        }
        public void Scenario1()
        {
            KongService service = null;

            this.Given(() => service = Fixture.Build <KongService>().Without(x => x.Id).Create(), "A new kong service")
            .And(s => s.KongRespondsCorrectly <KongService>(HttpMethod.Post, "/services/", service.ToJsonStringContent(), x => x.WithIdAndCreatedAt()),
                 KongRespondsCorrectlyToMethodAtPathTextTemplate)
            .When(async() => await Subject.AddService(service), Invoking(nameof(KongAdminWriter.AddService)))
            .Then(() => service.Id.Should().NotBeNullOrWhiteSpace(), "the Id is set")
            .BDDfy();
        }
Beispiel #7
0
 public async Task UpdateService(KongService service)
 {
     var content = service.ToJsonStringContent();
     await HttpClient.PatchAsync($"/services/{service.Id}", content);
 }