public async Task ExceptionthrownWhenGettingNetworksAndServerError() { var restResp = new HttpResponseAbstraction(new MemoryStream(), new HttpHeadersAbstraction(), HttpStatusCode.InternalServerError); this.NetworkServiceRestClient.Responses.Enqueue(restResp); var client = new NetworkServicePocoClient(GetValidContext(), this.ServiceLocator); await client.GetNetworks(); }
public async Task CanGetNetworksWithOkResponse() { var payload = @"{ ""networks"": [ { ""status"": ""ACTIVE"", ""subnets"": [ ""d3839504-ec4c-47a4-b7c7-07af079a48bb"" ], ""name"": ""myNetwork"", ""router:external"": false, ""tenant_id"": ""ffe683d1060449d09dac0bf9d7a371cd"", ""admin_state_up"": true, ""shared"": false, ""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.GetNetworks(); Assert.IsNotNull(result); var networks = result.ToList(); Assert.AreEqual(1, networks.Count()); var network = networks.First(); Assert.AreEqual("myNetwork", network.Name); Assert.AreEqual("12345", network.Id); Assert.AreEqual(NetworkStatus.Active, network.Status); }
public async Task CannotGetNetworksWithNoContent() { var restResp = new HttpResponseAbstraction(new MemoryStream(), new HttpHeadersAbstraction(), HttpStatusCode.NoContent); this.NetworkServiceRestClient.Responses.Enqueue(restResp); var client = new NetworkServicePocoClient(GetValidContext(), this.ServiceLocator); await client.GetNetworks(); }