コード例 #1
0
        public async Task CanGetNetworks()
        {
            var ntw1 = new OpenStack.Network.Network("12345","MyNetwork", NetworkStatus.Active);
            var ntw2 = new OpenStack.Network.Network("54321", "NetworkMy", NetworkStatus.Down);
            var networks = new List<OpenStack.Network.Network>() { ntw1, ntw2 };

            this.ServicePocoClient.GetNetworksDelegate = () => Task.Factory.StartNew(() => (IEnumerable<OpenStack.Network.Network>)networks);

            var client = new NetworkServiceClient(GetValidCreds(), "Neutron", CancellationToken.None, this.ServiceLocator);
            var resp = await client.GetNetworks();
            Assert.IsNotNull(resp);

            var respNetworks = resp.ToList();
            Assert.AreEqual(2, respNetworks.Count());
            Assert.AreEqual(ntw1, respNetworks[0]);
            Assert.AreEqual(ntw2, respNetworks[1]);
        }
コード例 #2
0
        private string GenerateNetworkPayload(OpenStack.Network.Network network)
        {
            var payloadFixture = @"{{
                ""status"": ""{2}"",
                ""subnets"": [
                    ""d3839504-ec4c-47a4-b7c7-07af079a48bb""
                ],
                ""name"": ""{0}"",
                ""router:external"": false,
                ""tenant_id"": ""ffe683d1060449d09dac0bf9d7a371cd"",
                ""admin_state_up"": true,
                ""shared"": false,
                ""id"": ""{1}""
            }}";

            return(string.Format(payloadFixture, network.Name, network.Id, network.Status.ToString().ToUpper()));
        }
コード例 #3
0
        public async Task CanGetNetworks()
        {
            var ntw1     = new OpenStack.Network.Network("12345", "MyNetwork", NetworkStatus.Active);
            var ntw2     = new OpenStack.Network.Network("54321", "NetworkMy", NetworkStatus.Down);
            var networks = new List <OpenStack.Network.Network>()
            {
                ntw1, ntw2
            };

            this.ServicePocoClient.GetNetworksDelegate = () => Task.Factory.StartNew(() => (IEnumerable <OpenStack.Network.Network>)networks);

            var client = new NetworkServiceClient(GetValidCreds(), "Neutron", CancellationToken.None, this.ServiceLocator);
            var resp   = await client.GetNetworks();

            Assert.IsNotNull(resp);

            var respNetworks = resp.ToList();

            Assert.AreEqual(2, respNetworks.Count());
            Assert.AreEqual(ntw1, respNetworks[0]);
            Assert.AreEqual(ntw2, respNetworks[1]);
        }