public async Task ExceptionthrownWhenGettingFloatingIpsAndServerError() { var restResp = new HttpResponseAbstraction(new MemoryStream(), new HttpHeadersAbstraction(), HttpStatusCode.InternalServerError); this.NetworkServiceRestClient.Responses.Enqueue(restResp); var client = new NetworkServicePocoClient(GetValidContext(), this.ServiceLocator); await client.GetFloatingIps(); }
public async Task CanGetFloatingIpsWithOkResponse() { var payload = @"{ ""floatingips"": [ { ""router_id"": ""fafac59b-a94a-4525-8700-f4f448e0ac97"", ""status"": ""ACTIVE"", ""tenant_id"": ""ffe683d1060449d09dac0bf9d7a371cd"", ""floating_network_id"": ""3eaab3f7-d3f2-430f-aa73-d07f39aae8f4"", ""fixed_ip_address"": ""10.0.0.2"", ""floating_ip_address"": ""172.0.0.1"", ""port_id"": ""9da94672-6e6b-446c-9579-3dd5484b31fd"", ""id"": ""12345"" } ] }"; var content = TestHelper.CreateStream(payload); var restResp = new HttpResponseAbstraction(content, new HttpHeadersAbstraction(), HttpStatusCode.OK); this.NetworkServiceRestClient.Responses.Enqueue(restResp); var client = new NetworkServicePocoClient(GetValidContext(), this.ServiceLocator); var result = await client.GetFloatingIps(); Assert.IsNotNull(result); var floatingIps = result.ToList(); Assert.AreEqual(1, floatingIps.Count()); var floatingIp = floatingIps.First(); Assert.AreEqual("12345", floatingIp.Id); Assert.AreEqual("172.0.0.1", floatingIp.FloatingIpAddress); Assert.AreEqual(FloatingIpStatus.Active, floatingIp.Status); }