Exemplo n.º 1
0
        public async Task AddRoute(string serviceId, KongRoute route)
        {
            var content  = route.ToJsonStringContent();
            var response = await HttpClient.PostAsync($"/services/{serviceId}/routes", content);

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

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

            route.Id      = added.Id;
            route.Service = added.Service;
        }
Exemplo n.º 2
0
        public async Task AddRoute(string serviceId, KongRoute route)
        {
            Log.Information(@"Adding route {route}", route);
            var content = route.ToJsonStringContent();

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

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

                var added = JsonConvert.DeserializeObject <KongRoute>(responseBody);
                route.Id      = added.Id;
                route.Service = added.Service;
            }
            catch (Exception e)
            {
                Log.Error(e, e.Message);
                throw;
            }
        }
Exemplo n.º 3
0
        public void Scenario5()
        {
            KongRoute route = null;

            this.Given(() => route = Fixture.Create <KongRoute>(), "A kong route")
            .And(s => s.KongRespondsCorrectly <KongRoute>(HttpMethod.Put, $"/routes/{route.Id}", route.ToJsonStringContent()),
                 KongRespondsCorrectlyToMethodAtPathTextTemplate)
            .When(async() => await Subject.PutRoute(route), Invoking(nameof(KongAdminWriter.PutRoute)))
            .Then("it succeeds")
            .BDDfy();
        }
Exemplo n.º 4
0
        public void Scenario4()
        {
            string    serviceId = Guid.NewGuid().ToString();
            KongRoute route     = null;

            this.Given(() => route = Fixture.Build <KongRoute>().Without(x => x.Id).Create(), "A new kong route")
            .And(s => s.KongRespondsCorrectly <KongRoute>(HttpMethod.Post, $"/services/{serviceId}/routes", route.ToJsonStringContent(), x => x.WithIdAndCreatedAtAndServiceReference(serviceId)),
                 KongRespondsCorrectlyToMethodAtPathTextTemplate)
            .When(async() => await Subject.AddRoute(serviceId, route), Invoking(nameof(KongAdminWriter.AddRoute)))
            .Then(() => route.Id.Should().NotBeNullOrWhiteSpace(), "the Id is set")
            .And(() => route.Service.Id.Should().Be(serviceId), "the ServiceReference is set")
            .BDDfy();
        }