public void TestEnableOrDisableBuildpackRequest()
        {
            string json = @"{
  ""enabled"": false
}";

            EnableOrDisableBuildpackRequest request = new EnableOrDisableBuildpackRequest();

            request.Enabled = false;
            string result = JsonConvert.SerializeObject(request, Formatting.None);
            Assert.AreEqual(TestUtil.ToUnformatedJsonString(json), result);
        }
Esempio n. 2
0
        public void TestEnableOrDisableBuildpackRequest()
        {
            string json = @"{
  ""enabled"": false
}";

            EnableOrDisableBuildpackRequest request = new EnableOrDisableBuildpackRequest();

            request.Enabled = false;
            string result = JsonConvert.SerializeObject(request, Formatting.None);

            Assert.AreEqual(TestUtil.ToUnformatedJsonString(json), result);
        }
        public void EnableOrDisableBuildpackTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""metadata"": {
    ""guid"": ""9a9405c5-c9e3-4ffe-870f-4ef4f0176530"",
    ""url"": ""/v2/buildpacks/9a9405c5-c9e3-4ffe-870f-4ef4f0176530"",
    ""created_at"": ""2015-04-16T12:04:19+00:00"",
    ""updated_at"": ""2015-04-16T12:04:19+00:00""
  },
  ""entity"": {
    ""name"": ""name_1"",
    ""position"": 1,
    ""enabled"": false,
    ""locked"": false,
    ""filename"": ""name-254""
  }
}";
                clients.JsonResponse = json;

                clients.ExpectedStatusCode = (HttpStatusCode)201;
                var cfClient = clients.CreateCloudFoundryClient();

                Guid?guid = Guid.NewGuid();

                EnableOrDisableBuildpackRequest value = new EnableOrDisableBuildpackRequest();


                var obj = cfClient.Buildpacks.EnableOrDisableBuildpack(guid, value).Result;


                Assert.AreEqual("9a9405c5-c9e3-4ffe-870f-4ef4f0176530", TestUtil.ToTestableString(obj.EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/buildpacks/9a9405c5-c9e3-4ffe-870f-4ef4f0176530", TestUtil.ToTestableString(obj.EntityMetadata.Url), true);
                Assert.AreEqual("2015-04-16T12:04:19+00:00", TestUtil.ToTestableString(obj.EntityMetadata.CreatedAt), true);
                Assert.AreEqual("2015-04-16T12:04:19+00:00", TestUtil.ToTestableString(obj.EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("name_1", TestUtil.ToTestableString(obj.Name), true);
                Assert.AreEqual("1", TestUtil.ToTestableString(obj.Position), true);
                Assert.AreEqual("false", TestUtil.ToTestableString(obj.Enabled), true);
                Assert.AreEqual("false", TestUtil.ToTestableString(obj.Locked), true);
                Assert.AreEqual("name-254", TestUtil.ToTestableString(obj.Filename), true);
            }
        }
Esempio n. 4
0
        public void EnableOrDisableBuildpackTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""metadata"": {
    ""guid"": ""e2ce18e2-0daa-44bb-a71a-27a947475045"",
    ""url"": ""/v2/buildpacks/e2ce18e2-0daa-44bb-a71a-27a947475045"",
    ""created_at"": ""2016-02-09T10:21:42Z"",
    ""updated_at"": ""2016-02-09T10:21:42Z""
  },
  ""entity"": {
    ""name"": ""name_1"",
    ""position"": 1,
    ""enabled"": false,
    ""locked"": false,
    ""filename"": ""name-134""
  }
}";
                clients.JsonResponse = json;

                clients.ExpectedStatusCode = (HttpStatusCode)201;
                var cfClient = clients.CreateCloudFoundryClient();

                Guid?guid = Guid.NewGuid();

                EnableOrDisableBuildpackRequest value = new EnableOrDisableBuildpackRequest();


                var obj = cfClient.Buildpacks.EnableOrDisableBuildpack(guid, value).Result;


                Assert.AreEqual("e2ce18e2-0daa-44bb-a71a-27a947475045", TestUtil.ToTestableString(obj.EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/buildpacks/e2ce18e2-0daa-44bb-a71a-27a947475045", TestUtil.ToTestableString(obj.EntityMetadata.Url), true);
                Assert.AreEqual("2016-02-09T10:21:42Z", TestUtil.ToTestableString(obj.EntityMetadata.CreatedAt), true);
                Assert.AreEqual("2016-02-09T10:21:42Z", TestUtil.ToTestableString(obj.EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("name_1", TestUtil.ToTestableString(obj.Name), true);
                Assert.AreEqual("1", TestUtil.ToTestableString(obj.Position), true);
                Assert.AreEqual("false", TestUtil.ToTestableString(obj.Enabled), true);
                Assert.AreEqual("false", TestUtil.ToTestableString(obj.Locked), true);
                Assert.AreEqual("name-134", TestUtil.ToTestableString(obj.Filename), true);
            }
        }
Esempio n. 5
0
        public void EnableOrDisableBuildpackTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""metadata"": {
    ""guid"": ""d492e98d-2c9c-4aa0-b78f-c60d90bbe689"",
    ""url"": ""/v2/buildpacks/f60828d8-1bf1-4cb0-8a14-4e4861b4f1c8"",
    ""created_at"": ""2016-09-02T11:52:12Z"",
    ""updated_at"": ""2016-09-02T11:52:12Z""
  },
  ""entity"": {
    ""name"": ""name_1"",
    ""position"": 1,
    ""enabled"": false,
    ""locked"": false,
    ""filename"": ""name-875""
  }
}";
                clients.JsonResponse = json;

                clients.ExpectedStatusCode = (HttpStatusCode)201;
                var cfClient = clients.CreateCloudFoundryClient();

                Guid?guid = Guid.NewGuid();

                EnableOrDisableBuildpackRequest value = new EnableOrDisableBuildpackRequest();


                var obj = cfClient.Buildpacks.EnableOrDisableBuildpack(guid, value).Result;


                Assert.AreEqual("d492e98d-2c9c-4aa0-b78f-c60d90bbe689", TestUtil.ToTestableString(obj.EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/buildpacks/f60828d8-1bf1-4cb0-8a14-4e4861b4f1c8", TestUtil.ToTestableString(obj.EntityMetadata.Url), true);
                Assert.AreEqual("2016-09-02T11:52:12Z", TestUtil.ToTestableString(obj.EntityMetadata.CreatedAt), true);
                Assert.AreEqual("2016-09-02T11:52:12Z", TestUtil.ToTestableString(obj.EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("name_1", TestUtil.ToTestableString(obj.Name), true);
                Assert.AreEqual("1", TestUtil.ToTestableString(obj.Position), true);
                Assert.AreEqual("false", TestUtil.ToTestableString(obj.Enabled), true);
                Assert.AreEqual("false", TestUtil.ToTestableString(obj.Locked), true);
                Assert.AreEqual("name-875", TestUtil.ToTestableString(obj.Filename), true);
            }
        }
        /// <summary>
        /// Enable or disable a Buildpack
        /// <para>For detailed information, see online documentation at: "http://apidocs.cloudfoundry.org/195/buildpacks/enable_or_disable_a_buildpack.html"</para>
        /// </summary>
        public async Task <EnableOrDisableBuildpackResponse> EnableOrDisableBuildpack(Guid?guid, EnableOrDisableBuildpackRequest value)
        {
            UriBuilder uriBuilder = new UriBuilder(this.Client.CloudTarget);

            uriBuilder.Path = string.Format(CultureInfo.InvariantCulture, "/v2/buildpacks/{0}", guid);
            var client = this.GetHttpClient();

            client.Uri    = uriBuilder.Uri;
            client.Method = HttpMethod.Put;
            client.Headers.Add(await BuildAuthenticationHeader());
            client.ContentType = "application/x-www-form-urlencoded";
            client.Content     = JsonConvert.SerializeObject(value).ConvertToStream();
            var expectedReturnStatus = 201;
            var response             = await this.SendAsync(client, expectedReturnStatus);

            return(Utilities.DeserializeJson <EnableOrDisableBuildpackResponse>(await response.ReadContentAsStringAsync()));
        }
Esempio n. 7
0
 /// <summary>
 /// Enable or disable a Buildpack
 /// <para>For detailed information, see online documentation at: "http://apidocs.cloudfoundry.org/195/buildpacks/enable_or_disable_a_buildpack.html"</para>
 /// </summary>
 public async Task<EnableOrDisableBuildpackResponse> EnableOrDisableBuildpack(Guid? guid, EnableOrDisableBuildpackRequest value)
 {
     UriBuilder uriBuilder = new UriBuilder(this.Client.CloudTarget);
     uriBuilder.Path = string.Format(CultureInfo.InvariantCulture, "/v2/buildpacks/{0}", guid);
     var client = this.GetHttpClient();
     client.Uri = uriBuilder.Uri;
     client.Method = HttpMethod.Put;
     var authHeader = await BuildAuthenticationHeader();
     if (!string.IsNullOrWhiteSpace(authHeader.Key))
     {
         client.Headers.Add(authHeader);
     }
     client.ContentType = "application/x-www-form-urlencoded";
     client.Content = JsonConvert.SerializeObject(value).ConvertToStream();
     var expectedReturnStatus = 201;
     var response = await this.SendAsync(client, expectedReturnStatus);
     return Utilities.DeserializeJson<EnableOrDisableBuildpackResponse>(await response.ReadContentAsStringAsync());
 }
        public void EnableOrDisableBuildpackTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""metadata"": {
    ""guid"": ""9c7095eb-f19e-4eb2-a986-f2e992dad864"",
    ""url"": ""/v2/buildpacks/9c7095eb-f19e-4eb2-a986-f2e992dad864"",
    ""created_at"": ""2015-05-19T15:27:21+00:00"",
    ""updated_at"": ""2015-05-19T15:27:21+00:00""
  },
  ""entity"": {
    ""name"": ""name_1"",
    ""position"": 1,
    ""enabled"": false,
    ""locked"": false,
    ""filename"": ""name-1683""
  }
}";
                clients.JsonResponse = json;

                clients.ExpectedStatusCode = (HttpStatusCode)201;
                var cfClient = clients.CreateCloudFoundryClient();

                Guid? guid = Guid.NewGuid();

                EnableOrDisableBuildpackRequest value = new EnableOrDisableBuildpackRequest();


                var obj = cfClient.Buildpacks.EnableOrDisableBuildpack(guid, value).Result;


                Assert.AreEqual("9c7095eb-f19e-4eb2-a986-f2e992dad864", TestUtil.ToTestableString(obj.EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/buildpacks/9c7095eb-f19e-4eb2-a986-f2e992dad864", TestUtil.ToTestableString(obj.EntityMetadata.Url), true);
                Assert.AreEqual("2015-05-19T15:27:21+00:00", TestUtil.ToTestableString(obj.EntityMetadata.CreatedAt), true);
                Assert.AreEqual("2015-05-19T15:27:21+00:00", TestUtil.ToTestableString(obj.EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("name_1", TestUtil.ToTestableString(obj.Name), true);
                Assert.AreEqual("1", TestUtil.ToTestableString(obj.Position), true);
                Assert.AreEqual("false", TestUtil.ToTestableString(obj.Enabled), true);
                Assert.AreEqual("false", TestUtil.ToTestableString(obj.Locked), true);
                Assert.AreEqual("name-1683", TestUtil.ToTestableString(obj.Filename), true);

            }
        }