/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { GetConnectionResponse response = new GetConnectionResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("connectedAt", targetDepth)) { var unmarshaller = DateTimeUnmarshaller.Instance; response.ConnectedAt = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("identity", targetDepth)) { var unmarshaller = IdentityUnmarshaller.Instance; response.Identity = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("lastActiveAt", targetDepth)) { var unmarshaller = DateTimeUnmarshaller.Instance; response.LastActiveAt = unmarshaller.Unmarshall(context); continue; } } return(response); }
public async Task GetConnectionResponse_using_System_Text_Json() { GetConnectionRequest.ConnectionId = CreateInvitationResponse.ConnectionRecord.Id; GetConnectionResponse getConnectionResponse = await HttpClient.GetFromJsonAsync <GetConnectionResponse>(GetConnectionRequest.GetRoute()); ValidateGetConnectionResponse(GetConnectionRequest, getConnectionResponse); }
public async Task GetConnectionResponse_using_Json_Net() { GetConnectionRequest.ConnectionId = CreateInvitationResponse.ConnectionRecord.Id; GetConnectionResponse getConnectionResponse = await GetJsonAsync <GetConnectionResponse>(GetConnectionRequest.GetRoute()); ValidateGetConnectionResponse(GetConnectionRequest, getConnectionResponse); }
public async Task GetConnectionResponse() { // Arrange CreateInvitationResponse createInvitationResponse = await CreateAnInvitation(); GetConnectionRequest.ConnectionId = createInvitationResponse.ConnectionRecord.Id; //Act GetConnectionResponse GetConnectionResponse = await Send(GetConnectionRequest); //Assert ValidateGetConnectionResponse(GetConnectionRequest, GetConnectionResponse); }
public async Task DeleteConnectionResponse() { DeleteConnectionRequest.ConnectionId = CreateInvitationResponse.ConnectionRecord.Id; DeleteConnectionResponse deleteConnectionResponse = await Send(DeleteConnectionRequest); ValidateDeleteConnectionResponse(DeleteConnectionRequest, deleteConnectionResponse); //Confirm it is deleted GetConnectionResponse getConnectionResponse = await Send(new GetConnectionRequest(CreateInvitationResponse.ConnectionRecord.Id)); getConnectionResponse.ConnectionRecord.Should().BeNull(); }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { GetConnectionResponse response = new GetConnectionResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("Connection", targetDepth)) { var unmarshaller = ConnectionUnmarshaller.Instance; response.Connection = unmarshaller.Unmarshall(context); continue; } } return(response); }
internal static void ValidateGetConnectionResponse(GetConnectionRequest aGetConnectionRequest, GetConnectionResponse aGetConnectionResponse) { aGetConnectionResponse.CorrelationId.Should().Be(aGetConnectionRequest.CorrelationId); aGetConnectionResponse.ConnectionRecord.Should().NotBeNull(); aGetConnectionResponse.ConnectionRecord.Alias.Name.Should().BeNull(); aGetConnectionResponse.ConnectionRecord.Alias.ImageUrl.Should().BeNull(); aGetConnectionResponse.ConnectionRecord.CreatedAtUtc.HasValue.Should().BeTrue(); aGetConnectionResponse.ConnectionRecord.Endpoint.Should().BeNull(); aGetConnectionResponse.ConnectionRecord.MultiPartyInvitation.Should().BeFalse(); aGetConnectionResponse.ConnectionRecord.Id.Should().Be(aGetConnectionRequest.ConnectionId); aGetConnectionResponse.ConnectionRecord.MyDid.Should().BeNull(); aGetConnectionResponse.ConnectionRecord.MyVk.Should().BeNull(); aGetConnectionResponse.ConnectionRecord.State.Should().Be(ConnectionState.Invited); aGetConnectionResponse.ConnectionRecord.TheirDid.Should().BeNull(); aGetConnectionResponse.ConnectionRecord.TheirVk.Should().BeNull(); aGetConnectionResponse.ConnectionRecord.TypeName.Should().Be("AF.ConnectionRecord"); aGetConnectionResponse.ConnectionRecord.UpdatedAtUtc.HasValue.Should().BeFalse(); }