Ejemplo n.º 1
0
        public async Task ListVlans_Paged_Success()
        {
            CloudControlClient client = CreateCloudControlClientWithUserAccount(request =>
            {
                MessageAssert.AcceptsMediaType(request,
                                               "application/json"
                                               );
                MessageAssert.HasRequestUri(request,
                                            CreateApiUri($"caas/2.4/{TestOrganizationId}/network/vlan?networkDomainId=909dd855-4b2c-49a9-8151-46969a1a9380&pageNumber=1&pageSize=250")
                                            );

                return(request.CreateResponse(HttpStatusCode.OK,
                                              responseBody: TestResponses.ListVlans_Success,
                                              mediaType: "application/json"
                                              ));
            });

            using (client)
            {
                Vlans vlans = await client.ListVlans(
                    networkDomainId : new Guid("909dd855-4b2c-49a9-8151-46969a1a9380"),
                    paging : new Paging
                {
                    PageNumber = 1,
                    PageSize   = 250
                }
                    );

                Assert.NotNull(vlans);
                Assert.Equal(1, vlans.TotalCount);
                Assert.Equal(1, vlans.Items.Count);
            }
        }
        public async Task ListNetworkDomains_Paged_Success()
        {
            CloudControlClient client = CreateCloudControlClientWithUserAccount(request =>
            {
                MessageAssert.AcceptsMediaType(request,
                                               "application/json"
                                               );
                MessageAssert.HasRequestUri(request,
                                            CreateApiUri($"caas/2.4/{TestOrganizationId}/network/networkDomain?datacenterId=AU9&pageNumber=1&pageSize=250")
                                            );

                return(request.CreateResponse(HttpStatusCode.OK,
                                              responseBody: TestResponses.ListNetworkDomains_Success,
                                              mediaType: "application/json"
                                              ));
            });

            using (client)
            {
                NetworkDomainQuery query  = NetworkDomainQuery.ByDatacenter("AU9");
                Paging             paging = new Paging
                {
                    PageNumber = 1,
                    PageSize   = 250
                };

                NetworkDomains networkDomains = await client.ListNetworkDomains(query, paging);

                Assert.NotNull(networkDomains);
                Assert.Equal(2, networkDomains.TotalCount);
                Assert.Equal(2, networkDomains.Items.Count);
            }
        }
        public async Task Get_Account_Success()
        {
            CloudControlClient client = CreateCloudControlClient(request =>
            {
                MessageAssert.AcceptsMediaType(request, "text/xml");
                MessageAssert.HasRequestUri(request,
                                            CreateApiUri("oec/0.9/myaccount")
                                            );

                return(request.CreateResponse(HttpStatusCode.OK, MyAccountXml, mediaType: "text/xml"));
            });

            using (client)
            {
                UserAccount account = await client.GetAccount();

                Assert.NotNull(account);
                Assert.Equal("test_user", account.UserName);
                Assert.Equal("Test User", account.FullName);
                Assert.Equal("Test", account.FirstName);
                Assert.Equal("User", account.LastName);
                Assert.Equal("*****@*****.**", account.EmailAddress);
                Assert.Equal("Department 1", account.Department);
                Assert.Equal(TestOrganizationId, account.OrganizationId);
            }
        }
        public async Task CreateNetworkDomain_Success()
        {
            CloudControlClient client = CreateCloudControlClientWithUserAccount(async request =>
            {
                MessageAssert.AcceptsMediaType(request,
                                               "application/json"
                                               );
                MessageAssert.HasRequestUri(request,
                                            CreateApiUri($"caas/2.4/{TestOrganizationId}/network/deployNetworkDomain")
                                            );

                JObject expectedRequestBody = (JObject)JToken.Parse(
                    TestRequests.CreateNetworkDomain_Success
                    );

                JObject actualRequestBody = (JObject)JToken.Parse(
                    await request.Content.ReadAsStringAsync()
                    );

                Assert.Equal(
                    expectedRequestBody.ToString(Formatting.Indented).Trim(),
                    actualRequestBody.ToString(Formatting.Indented).Trim()
                    );

                return(request.CreateResponse(HttpStatusCode.OK,
                                              responseBody: TestResponses.CreateNetworkDomain_Success,
                                              mediaType: "application/json"
                                              ));
            });

            using (client)
            {
                Guid expectedNetworkDomainId = new Guid("f14a871f-9a25-470c-aef8-51e13202e1aa");
                Guid actualNetworkDomainId   = await client.CreateNetworkDomain(
                    datacenterId : "AU9",
                    name : "A Network Domain",
                    description : "This is a network domain",
                    type : NetworkDomainType.Essentials
                    );

                Assert.Equal(
                    expectedNetworkDomainId,
                    actualNetworkDomainId
                    );
            }
        }