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

            await client.GetServer("12345");

            Assert.IsTrue(this.simulator.Headers.ContainsKey("X-Auth-Token"));
            Assert.AreEqual(this.authId, this.simulator.Headers["X-Auth-Token"]);
        }
Esempio n. 2
0
        public async Task GetComputeServerFormsCorrectUrlAndMethod()
        {
            var serverId = "1";
            var client   =
                new ComputeServiceRestClient(GetValidContext(), this.ServiceLocator);

            await client.GetServer(serverId);

            Assert.AreEqual(string.Format("{0}/servers/{1}", endpoint, serverId), this.simulator.Uri.ToString());
            Assert.AreEqual(HttpMethod.Get, this.simulator.Method);
        }
Esempio n. 3
0
        public async Task CanGetServer()
        {
            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.GetServer(serverId);

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

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

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