public async Task GetNetworksIncludesAuthHeader()
        {
            var client =
                new NetworkServiceRestClient(GetValidContext(), this.ServiceLocator);

            await client.GetNetworks();

            Assert.IsTrue(this.simulator.Headers.ContainsKey("X-Auth-Token"));
            Assert.AreEqual(this.authId, this.simulator.Headers["X-Auth-Token"]);
        }
        public async Task CanGetNetworks()
        {
            this.simulator.Networks.Add(new OpenStack.Network.Network("12345","MyNetwork", NetworkStatus.Active));

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

            var resp = await client.GetNetworks();

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

            var respContent = TestHelper.GetStringFromStream(resp.Content);
            Assert.IsTrue(respContent.Length > 0);
        }
        public async Task GetNetworksFormsCorrectUrlAndMethod()
        {
            var client =
                new NetworkServiceRestClient(GetValidContext(), this.ServiceLocator);

            await client.GetNetworks();

            Assert.AreEqual(string.Format("{0}/networks", endpoint +"v2.0"), this.simulator.Uri.ToString());
            Assert.AreEqual(HttpMethod.Get, this.simulator.Method);
        }
        public async Task CanDeleteFloatinIp()
        {
            this.simulator.FloatingIps.Add(new FloatingIp("12345", "172.0.0.1", FloatingIpStatus.Active));
            var client =
               new NetworkServiceRestClient(GetValidContext(), this.ServiceLocator);

            var resp = await client.DeleteFloatingIp("12345");

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

            Assert.AreEqual(0, this.simulator.FloatingIps.Count);
        }
        public async Task DeleteFloatingIpFormsCorrectUrlAndMethod()
        {
            var floatingIpId = "12345";
            var client =
                new NetworkServiceRestClient(GetValidContext(), this.ServiceLocator);

            await client.DeleteFloatingIp(floatingIpId);

            Assert.AreEqual(string.Format("{0}/floatingips/{1}", endpoint + "v2.0", floatingIpId), this.simulator.Uri.ToString());
            Assert.AreEqual(HttpMethod.Delete, this.simulator.Method);
        }
        public async Task CreateFloatinIpFormCorrectBody()
        {
            var client =
               new NetworkServiceRestClient(GetValidContext(), this.ServiceLocator);

            var resp = await client.CreateFloatingIp("12345");

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

            this.simulator.Content.Position = 0;
            var body = TestHelper.GetStringFromStream(this.simulator.Content);
            var ipObj = JObject.Parse(body);
            Assert.IsNotNull(ipObj);
            Assert.IsNotNull(ipObj["floatingip"]);
            Assert.IsNotNull(ipObj["floatingip"]["floating_network_id"]);
            Assert.AreEqual("12345", (string)ipObj["floatingip"]["floating_network_id"]);
        }
        public async Task CanCreateFloatinIp()
        {
            var client =
               new NetworkServiceRestClient(GetValidContext(), this.ServiceLocator);

            var resp = await client.CreateFloatingIp("12345");

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

            var respContent = TestHelper.GetStringFromStream(resp.Content);
            Assert.IsTrue(respContent.Length > 0);
        }
        public async Task CreateFloatingIpFormsCorrectUrlAndMethod()
        {
            var client =
                new NetworkServiceRestClient(GetValidContext(), this.ServiceLocator);

            await client.CreateFloatingIp("12345");

            Assert.AreEqual(string.Format("{0}/floatingips", endpoint + "v2.0"), this.simulator.Uri.ToString());
            Assert.AreEqual(HttpMethod.Post, this.simulator.Method);
        }