public void TestChangePositionOfBuildpackRequest() { string json = @"{ ""position"": 3 }"; ChangePositionOfBuildpackRequest request = new ChangePositionOfBuildpackRequest(); request.Position = 3; string result = JsonConvert.SerializeObject(request, Formatting.None); Assert.AreEqual(TestUtil.ToUnformatedJsonString(json), result); }
public void ChangePositionOfBuildpackTest() { using (ShimsContext.Create()) { MockClients clients = new MockClients(); string json = @"{ ""metadata"": { ""guid"": ""c428eba4-dbc5-4034-bf21-5bdad5335d84"", ""url"": ""/v2/buildpacks/c428eba4-dbc5-4034-bf21-5bdad5335d84"", ""created_at"": ""2015-05-19T15:27:21+00:00"", ""updated_at"": ""2015-05-19T15:27:21+00:00"" }, ""entity"": { ""name"": ""name_1"", ""position"": 3, ""enabled"": true, ""locked"": false, ""filename"": ""name-1689"" } }"; clients.JsonResponse = json; clients.ExpectedStatusCode = (HttpStatusCode)201; var cfClient = clients.CreateCloudFoundryClient(); Guid? guid = Guid.NewGuid(); ChangePositionOfBuildpackRequest value = new ChangePositionOfBuildpackRequest(); var obj = cfClient.Buildpacks.ChangePositionOfBuildpack(guid, value).Result; Assert.AreEqual("c428eba4-dbc5-4034-bf21-5bdad5335d84", TestUtil.ToTestableString(obj.EntityMetadata.Guid), true); Assert.AreEqual("/v2/buildpacks/c428eba4-dbc5-4034-bf21-5bdad5335d84", 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("3", TestUtil.ToTestableString(obj.Position), true); Assert.AreEqual("true", TestUtil.ToTestableString(obj.Enabled), true); Assert.AreEqual("false", TestUtil.ToTestableString(obj.Locked), true); Assert.AreEqual("name-1689", TestUtil.ToTestableString(obj.Filename), true); } }
public void ChangePositionOfBuildpackTest() { using (ShimsContext.Create()) { MockClients clients = new MockClients(); string json = @"{ ""metadata"": { ""guid"": ""41c9f9bc-6af7-4265-b6af-061b6063c0d6"", ""url"": ""/v2/buildpacks/41c9f9bc-6af7-4265-b6af-061b6063c0d6"", ""created_at"": ""2015-04-16T12:04:19+00:00"", ""updated_at"": ""2015-04-16T12:04:19+00:00"" }, ""entity"": { ""name"": ""name_1"", ""position"": 3, ""enabled"": true, ""locked"": false, ""filename"": ""name-248"" } }"; clients.JsonResponse = json; clients.ExpectedStatusCode = (HttpStatusCode)201; var cfClient = clients.CreateCloudFoundryClient(); Guid?guid = Guid.NewGuid(); ChangePositionOfBuildpackRequest value = new ChangePositionOfBuildpackRequest(); var obj = cfClient.Buildpacks.ChangePositionOfBuildpack(guid, value).Result; Assert.AreEqual("41c9f9bc-6af7-4265-b6af-061b6063c0d6", TestUtil.ToTestableString(obj.EntityMetadata.Guid), true); Assert.AreEqual("/v2/buildpacks/41c9f9bc-6af7-4265-b6af-061b6063c0d6", 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("3", TestUtil.ToTestableString(obj.Position), true); Assert.AreEqual("true", TestUtil.ToTestableString(obj.Enabled), true); Assert.AreEqual("false", TestUtil.ToTestableString(obj.Locked), true); Assert.AreEqual("name-248", TestUtil.ToTestableString(obj.Filename), true); } }
public void ChangePositionOfBuildpackTest() { using (ShimsContext.Create()) { MockClients clients = new MockClients(); string json = @"{ ""metadata"": { ""guid"": ""9cceb7f2-6148-42a7-ad22-87081ec6218a"", ""url"": ""/v2/buildpacks/9cceb7f2-6148-42a7-ad22-87081ec6218a"", ""created_at"": ""2016-02-09T10:21:42Z"", ""updated_at"": ""2016-02-09T10:21:42Z"" }, ""entity"": { ""name"": ""name_1"", ""position"": 3, ""enabled"": true, ""locked"": false, ""filename"": ""name-131"" } }"; clients.JsonResponse = json; clients.ExpectedStatusCode = (HttpStatusCode)201; var cfClient = clients.CreateCloudFoundryClient(); Guid?guid = Guid.NewGuid(); ChangePositionOfBuildpackRequest value = new ChangePositionOfBuildpackRequest(); var obj = cfClient.Buildpacks.ChangePositionOfBuildpack(guid, value).Result; Assert.AreEqual("9cceb7f2-6148-42a7-ad22-87081ec6218a", TestUtil.ToTestableString(obj.EntityMetadata.Guid), true); Assert.AreEqual("/v2/buildpacks/9cceb7f2-6148-42a7-ad22-87081ec6218a", 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("3", TestUtil.ToTestableString(obj.Position), true); Assert.AreEqual("true", TestUtil.ToTestableString(obj.Enabled), true); Assert.AreEqual("false", TestUtil.ToTestableString(obj.Locked), true); Assert.AreEqual("name-131", TestUtil.ToTestableString(obj.Filename), true); } }
public void ChangePositionOfBuildpackTest() { using (ShimsContext.Create()) { MockClients clients = new MockClients(); string json = @"{ ""metadata"": { ""guid"": ""2be1ca65-c2cb-44bf-9cda-f2a7b627f94d"", ""url"": ""/v2/buildpacks/4246c3cc-eb62-475b-93a3-72d4fc7506fe"", ""created_at"": ""2016-09-02T11:52:12Z"", ""updated_at"": ""2016-09-02T11:52:12Z"" }, ""entity"": { ""name"": ""name_1"", ""position"": 3, ""enabled"": true, ""locked"": false, ""filename"": ""name-869"" } }"; clients.JsonResponse = json; clients.ExpectedStatusCode = (HttpStatusCode)201; var cfClient = clients.CreateCloudFoundryClient(); Guid?guid = Guid.NewGuid(); ChangePositionOfBuildpackRequest value = new ChangePositionOfBuildpackRequest(); var obj = cfClient.Buildpacks.ChangePositionOfBuildpack(guid, value).Result; Assert.AreEqual("2be1ca65-c2cb-44bf-9cda-f2a7b627f94d", TestUtil.ToTestableString(obj.EntityMetadata.Guid), true); Assert.AreEqual("/v2/buildpacks/4246c3cc-eb62-475b-93a3-72d4fc7506fe", 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("3", TestUtil.ToTestableString(obj.Position), true); Assert.AreEqual("true", TestUtil.ToTestableString(obj.Enabled), true); Assert.AreEqual("false", TestUtil.ToTestableString(obj.Locked), true); Assert.AreEqual("name-869", TestUtil.ToTestableString(obj.Filename), true); } }
/// <summary> /// Change the position of a Buildpack /// <para>Buildpacks are maintained in an ordered list. If the target position is already occupied,</para> /// <para>the entries will be shifted down the list to make room. If the target position is beyond</para> /// <para>the end of the current list, the buildpack will be positioned at the end of the list.</para> /// <para>For detailed information, see online documentation at: "http://apidocs.cloudfoundry.org/195/buildpacks/change_the_position_of_a_buildpack.html"</para> /// </summary> public async Task<ChangePositionOfBuildpackResponse> ChangePositionOfBuildpack(Guid? guid, ChangePositionOfBuildpackRequest 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<ChangePositionOfBuildpackResponse>(await response.ReadContentAsStringAsync()); }
/// <summary> /// Change the position of a Buildpack /// <para>Buildpacks are maintained in an ordered list. If the target position is already occupied,</para> /// <para>the entries will be shifted down the list to make room. If the target position is beyond</para> /// <para>the end of the current list, the buildpack will be positioned at the end of the list.</para> /// <para>For detailed information, see online documentation at: "http://apidocs.cloudfoundry.org/195/buildpacks/change_the_position_of_a_buildpack.html"</para> /// </summary> public async Task <ChangePositionOfBuildpackResponse> ChangePositionOfBuildpack(Guid?guid, ChangePositionOfBuildpackRequest 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 <ChangePositionOfBuildpackResponse>(await response.ReadContentAsStringAsync())); }