Exemplo n.º 1
0
        public async Task GetComputeServersFormsCorrectUrlAndMethod()
        {
            var client =
                new ComputeServiceRestClient(GetValidContext(), this.ServiceLocator);

            await client.GetServers();

            Assert.AreEqual(string.Format("{0}/servers", endpoint), this.simulator.Uri.ToString());
            Assert.AreEqual(HttpMethod.Get, this.simulator.Method);
        }
Exemplo n.º 2
0
        public async Task GetComputeServersIncludesAuthHeader()
        {
            var client =
                new ComputeServiceRestClient(GetValidContext(), this.ServiceLocator);

            await client.GetServers();

            Assert.IsTrue(this.simulator.Headers.ContainsKey("X-Auth-Token"));
            Assert.AreEqual(this.authId, this.simulator.Headers["X-Auth-Token"]);
        }
Exemplo n.º 3
0
        public async Task CanGetServers()
        {
            var serverId = "12345";
            var server   = new ComputeServer(serverId, "tiny",
                                             new Uri("http://testcomputeendpoint.com/v2/1234567890/servers/1"),
                                             new Uri("http://testcomputeendpoint.com/1234567890/servers/1"), new Dictionary <string, string>());

            this.simulator.Servers.Add(server);

            var client = new ComputeServiceRestClient(GetValidContext(), this.ServiceLocator);

            var resp = await client.GetServers();

            Assert.AreEqual(HttpStatusCode.OK, resp.StatusCode);

            var respContent = TestHelper.GetStringFromStream(resp.Content);

            Assert.IsTrue(respContent.Length > 0);
        }