public async Task GetApplications() { var httpClient = CreateClient(); var linkFactory = StormPathDocument.CreateLinkFactory(); var tenantLink = new TenantLink() { TenantId = "5gG32HDHLSsYAWeh9ADSZo" }; var response = await httpClient.FollowLinkAsync(tenantLink); var stream = await response.Content.ReadAsStreamAsync(); var jtoken = JToken.Load(new JsonTextReader(new StreamReader(stream))); var stormpathdocument = StormPathDocument.Parse(jtoken,linkFactory); var tenantMessage = TenantLink.InterpretMessageBody(stormpathdocument); var response2 = await httpClient.FollowLinkAsync(tenantMessage.ApplicationsLink); var applicationsList = ApplicationsLink.InterpretMessageBody(response2.Content.Headers.ContentType, await response2.Content.ReadAsStreamAsync(), linkFactory); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.NotNull(applicationsList); }
public async Task GetTenant() { var httpClient = CreateClient(); var linkFactory = StormPathDocument.CreateLinkFactory(); var tenantLink = new TenantLink() { TenantId = "5gG32HDHLSsYAWeh9ADSZo" }; TenantMessage tenantMessage = null; var machine = new HttpResponseMachine(); machine.AddResponseHandler(new RedirectHandler(httpClient, machine).HandleResponseAsync, HttpStatusCode.Redirect); machine.AddResponseHandler(async (l, r) => { tenantMessage = tenantLink.InterpretMessageBody(r.Content.Headers.ContentType, await r.Content.ReadAsStreamAsync(), linkFactory); return r; }, HttpStatusCode.OK, LinkHelper.GetLinkRelationTypeName<TenantLink>() ,new MediaTypeHeaderValue("application/json"){CharSet="UTF-8"}); await httpClient.FollowLinkAsync(tenantLink, machine); Assert.NotNull(tenantMessage); }