Exemple #1
0
        public void CreateServicePlanDeprecatedTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""metadata"": {
    ""guid"": ""fd3f70a8-eaf1-4b46-a35a-652dbc3542ca"",
    ""url"": ""/v2/service_plans/fd3f70a8-eaf1-4b46-a35a-652dbc3542ca"",
    ""created_at"": ""2016-02-09T10:21:42Z"",
    ""updated_at"": null
  },
  ""entity"": {
    ""name"": ""100mb"",
    ""free"": true,
    ""description"": ""Let's you put data in your database!"",
    ""service_guid"": ""2d03c09b-e0fb-4cd2-a47d-3392fe3663b7"",
    ""extra"": null,
    ""unique_id"": ""b9708803-b407-4934-a495-5cc7dec3cc62"",
    ""public"": true,
    ""active"": true,
    ""service_url"": ""/v2/services/2d03c09b-e0fb-4cd2-a47d-3392fe3663b7"",
    ""service_instances_url"": ""/v2/service_plans/fd3f70a8-eaf1-4b46-a35a-652dbc3542ca/service_instances""
  }
}";
                clients.JsonResponse = json;

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

                CreateServicePlanDeprecatedRequest value = new CreateServicePlanDeprecatedRequest();


                var obj = cfClient.ServicePlans.CreateServicePlanDeprecated(value).Result;


                Assert.AreEqual("fd3f70a8-eaf1-4b46-a35a-652dbc3542ca", TestUtil.ToTestableString(obj.EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/service_plans/fd3f70a8-eaf1-4b46-a35a-652dbc3542ca", TestUtil.ToTestableString(obj.EntityMetadata.Url), true);
                Assert.AreEqual("2016-02-09T10:21:42Z", TestUtil.ToTestableString(obj.EntityMetadata.CreatedAt), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("100mb", TestUtil.ToTestableString(obj.Name), true);
                Assert.AreEqual("true", TestUtil.ToTestableString(obj.Free), true);
                Assert.AreEqual("Let's you put data in your database!", TestUtil.ToTestableString(obj.Description), true);
                Assert.AreEqual("2d03c09b-e0fb-4cd2-a47d-3392fe3663b7", TestUtil.ToTestableString(obj.ServiceGuid), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.Extra), true);
                Assert.AreEqual("b9708803-b407-4934-a495-5cc7dec3cc62", TestUtil.ToTestableString(obj.UniqueId), true);
                Assert.AreEqual("true", TestUtil.ToTestableString(obj.Public), true);
                Assert.AreEqual("true", TestUtil.ToTestableString(obj.Active), true);
                Assert.AreEqual("/v2/services/2d03c09b-e0fb-4cd2-a47d-3392fe3663b7", TestUtil.ToTestableString(obj.ServiceUrl), true);
                Assert.AreEqual("/v2/service_plans/fd3f70a8-eaf1-4b46-a35a-652dbc3542ca/service_instances", TestUtil.ToTestableString(obj.ServiceInstancesUrl), true);
            }
        }
        public void CreateServicePlanDeprecatedTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""metadata"": {
    ""guid"": ""dc5c468a-3b14-41f5-8f4d-520430f16d27"",
    ""url"": ""/v2/service_plans/dc5c468a-3b14-41f5-8f4d-520430f16d27"",
    ""created_at"": ""2015-04-16T12:04:29+00:00"",
    ""updated_at"": null
  },
  ""entity"": {
    ""name"": ""100mb"",
    ""free"": true,
    ""description"": ""Let's you put data in your database!"",
    ""service_guid"": ""97cdef48-22fa-4901-944a-e943586677bd"",
    ""extra"": null,
    ""unique_id"": ""4a42521f-9e4a-4407-936f-795e997cecb2"",
    ""public"": true,
    ""active"": true,
    ""service_url"": ""/v2/services/97cdef48-22fa-4901-944a-e943586677bd"",
    ""service_instances_url"": ""/v2/service_plans/dc5c468a-3b14-41f5-8f4d-520430f16d27/service_instances""
  }
}";
                clients.JsonResponse = json;

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

                CreateServicePlanDeprecatedRequest value = new CreateServicePlanDeprecatedRequest();


                var obj = cfClient.ServicePlans.CreateServicePlanDeprecated(value).Result;


                Assert.AreEqual("dc5c468a-3b14-41f5-8f4d-520430f16d27", TestUtil.ToTestableString(obj.EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/service_plans/dc5c468a-3b14-41f5-8f4d-520430f16d27", TestUtil.ToTestableString(obj.EntityMetadata.Url), true);
                Assert.AreEqual("2015-04-16T12:04:29+00:00", TestUtil.ToTestableString(obj.EntityMetadata.CreatedAt), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("100mb", TestUtil.ToTestableString(obj.Name), true);
                Assert.AreEqual("true", TestUtil.ToTestableString(obj.Free), true);
                Assert.AreEqual("Let's you put data in your database!", TestUtil.ToTestableString(obj.Description), true);
                Assert.AreEqual("97cdef48-22fa-4901-944a-e943586677bd", TestUtil.ToTestableString(obj.ServiceGuid), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.Extra), true);
                Assert.AreEqual("4a42521f-9e4a-4407-936f-795e997cecb2", TestUtil.ToTestableString(obj.UniqueId), true);
                Assert.AreEqual("true", TestUtil.ToTestableString(obj.Public), true);
                Assert.AreEqual("true", TestUtil.ToTestableString(obj.Active), true);
                Assert.AreEqual("/v2/services/97cdef48-22fa-4901-944a-e943586677bd", TestUtil.ToTestableString(obj.ServiceUrl), true);
                Assert.AreEqual("/v2/service_plans/dc5c468a-3b14-41f5-8f4d-520430f16d27/service_instances", TestUtil.ToTestableString(obj.ServiceInstancesUrl), true);
            }
        }
        public void TestCreateServicePlanDeprecatedRequest()
        {
            string json = @"{
  ""name"": ""100mb"",
  ""free"": true,
  ""description"": ""Let's you put data in your database!"",
  ""service_guid"": ""ba0b0617-aaff-4953-8b45-dbdf861502d0""
}";

            CreateServicePlanDeprecatedRequest request = new CreateServicePlanDeprecatedRequest();

            request.Name = "100mb";
            request.Free = true;
            request.Description = "Let's you put data in your database!";
            request.ServiceGuid = new Guid("ba0b0617-aaff-4953-8b45-dbdf861502d0");
            string result = JsonConvert.SerializeObject(request, Formatting.None);
            Assert.AreEqual(TestUtil.ToUnformatedJsonString(json), result);
        }
        public void TestCreateServicePlanDeprecatedRequest()
        {
            string json = @"{
  ""name"": ""100mb"",
  ""free"": true,
  ""description"": ""Let's you put data in your database!"",
  ""service_guid"": ""97cdef48-22fa-4901-944a-e943586677bd""
}";

            CreateServicePlanDeprecatedRequest request = new CreateServicePlanDeprecatedRequest();

            request.Name        = "100mb";
            request.Free        = true;
            request.Description = "Let's you put data in your database!";
            request.ServiceGuid = new Guid("97cdef48-22fa-4901-944a-e943586677bd");
            string result = JsonConvert.SerializeObject(request, Formatting.None);

            Assert.AreEqual(TestUtil.ToUnformatedJsonString(json), result);
        }
        public void TestCreateServicePlanDeprecatedRequest()
        {
            string json = @"{
  ""name"": ""100mb"",
  ""free"": true,
  ""description"": ""Let's you put data in your database!"",
  ""service_guid"": ""2d03c09b-e0fb-4cd2-a47d-3392fe3663b7""
}";

            CreateServicePlanDeprecatedRequest request = new CreateServicePlanDeprecatedRequest();

            request.Name        = "100mb";
            request.Free        = true;
            request.Description = "Let's you put data in your database!";
            request.ServiceGuid = new Guid("2d03c09b-e0fb-4cd2-a47d-3392fe3663b7");
            string result = JsonConvert.SerializeObject(request, Formatting.None);

            Assert.AreEqual(TestUtil.ToUnformatedJsonString(json), result);
        }
        /// <summary>
        /// Creating a Service Plan (deprecated)
        /// <para>For detailed information, see online documentation at: "http://apidocs.cloudfoundry.org/195/service_plans/creating_a_service_plan_(deprecated).html"</para>
        /// </summary>
        public async Task <CreateServicePlanDeprecatedResponse> CreateServicePlanDeprecated(CreateServicePlanDeprecatedRequest value)
        {
            UriBuilder uriBuilder = new UriBuilder(this.Client.CloudTarget);

            uriBuilder.Path = "/v2/service_plans";
            var client = this.GetHttpClient();

            client.Uri    = uriBuilder.Uri;
            client.Method = HttpMethod.Post;
            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 <CreateServicePlanDeprecatedResponse>(await response.ReadContentAsStringAsync()));
        }
 /// <summary>
 /// Creating a Service Plan (deprecated)
 /// <para>For detailed information, see online documentation at: "http://apidocs.cloudfoundry.org/195/service_plans/creating_a_service_plan_(deprecated).html"</para>
 /// </summary>
 public async Task<CreateServicePlanDeprecatedResponse> CreateServicePlanDeprecated(CreateServicePlanDeprecatedRequest value)
 {
     UriBuilder uriBuilder = new UriBuilder(this.Client.CloudTarget);
     uriBuilder.Path = "/v2/service_plans";
     var client = this.GetHttpClient();
     client.Uri = uriBuilder.Uri;
     client.Method = HttpMethod.Post;
     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<CreateServicePlanDeprecatedResponse>(await response.ReadContentAsStringAsync());
 }
        public void CreateServicePlanDeprecatedTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""metadata"": {
    ""guid"": ""b94f63ef-5d0d-45f6-bb43-6bdd49d7ed18"",
    ""url"": ""/v2/service_plans/b94f63ef-5d0d-45f6-bb43-6bdd49d7ed18"",
    ""created_at"": ""2015-05-19T15:27:03+00:00"",
    ""updated_at"": null
  },
  ""entity"": {
    ""name"": ""100mb"",
    ""free"": true,
    ""description"": ""Let's you put data in your database!"",
    ""service_guid"": ""ba0b0617-aaff-4953-8b45-dbdf861502d0"",
    ""extra"": null,
    ""unique_id"": ""0f05d666-2714-40fd-95ee-b252145ca55a"",
    ""public"": true,
    ""active"": true,
    ""service_url"": ""/v2/services/ba0b0617-aaff-4953-8b45-dbdf861502d0"",
    ""service_instances_url"": ""/v2/service_plans/b94f63ef-5d0d-45f6-bb43-6bdd49d7ed18/service_instances""
  }
}";
                clients.JsonResponse = json;

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

                CreateServicePlanDeprecatedRequest value = new CreateServicePlanDeprecatedRequest();


                var obj = cfClient.ServicePlans.CreateServicePlanDeprecated(value).Result;


                Assert.AreEqual("b94f63ef-5d0d-45f6-bb43-6bdd49d7ed18", TestUtil.ToTestableString(obj.EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/service_plans/b94f63ef-5d0d-45f6-bb43-6bdd49d7ed18", TestUtil.ToTestableString(obj.EntityMetadata.Url), true);
                Assert.AreEqual("2015-05-19T15:27:03+00:00", TestUtil.ToTestableString(obj.EntityMetadata.CreatedAt), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("100mb", TestUtil.ToTestableString(obj.Name), true);
                Assert.AreEqual("true", TestUtil.ToTestableString(obj.Free), true);
                Assert.AreEqual("Let's you put data in your database!", TestUtil.ToTestableString(obj.Description), true);
                Assert.AreEqual("ba0b0617-aaff-4953-8b45-dbdf861502d0", TestUtil.ToTestableString(obj.ServiceGuid), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.Extra), true);
                Assert.AreEqual("0f05d666-2714-40fd-95ee-b252145ca55a", TestUtil.ToTestableString(obj.UniqueId), true);
                Assert.AreEqual("true", TestUtil.ToTestableString(obj.Public), true);
                Assert.AreEqual("true", TestUtil.ToTestableString(obj.Active), true);
                Assert.AreEqual("/v2/services/ba0b0617-aaff-4953-8b45-dbdf861502d0", TestUtil.ToTestableString(obj.ServiceUrl), true);
                Assert.AreEqual("/v2/service_plans/b94f63ef-5d0d-45f6-bb43-6bdd49d7ed18/service_instances", TestUtil.ToTestableString(obj.ServiceInstancesUrl), true);

            }
        }