コード例 #1
0
        public async Task CanGetServers()
        {
            var expServer1 = new ComputeServer("1", "srv1",
                new Uri("http://testcomputeendpoint.com/v2/1234567890/servers/1"),
                new Uri("http://testcomputeendpoint.com/1234567890/servers/1"), new Dictionary<string, string>());

            var expServer2 = new ComputeServer("2", "srv2",
                new Uri("http://testcomputeendpoint.com/v2/1234567890/servers/1"),
                new Uri("http://testcomputeendpoint.com/1234567890/servers/1"), new Dictionary<string, string>());
            var servers = new List<ComputeServer>() { expServer1, expServer2 };

            this.ServicePocoClient.GetServersDelegate = () => Task.Factory.StartNew(() => (IEnumerable<ComputeServer>)servers);

            var client = new ComputeServiceClient(GetValidCreds(), "Nova", CancellationToken.None, this.ServiceLocator);
            var resp = await client.GetServers();
            Assert.IsNotNull(resp);

            var respFlavors = resp.ToList();
            Assert.AreEqual(2, respFlavors.Count());
            Assert.AreEqual(expServer1, respFlavors[0]);
            Assert.AreEqual(expServer2, respFlavors[1]);
        }