/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { DescribeVpcsResponse response = new DescribeVpcsResponse(); int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) targetDepth = 2; while (context.ReadAtDepth(originalDepth)) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("vpcSet/item", targetDepth)) { var unmarshaller = VpcUnmarshaller.Instance; var item = unmarshaller.Unmarshall(context); response.Vpcs.Add(item); continue; } } } return response; }
public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { DescribeVpcsResponse response = new DescribeVpcsResponse(); int targetDepth = 2; while (context.Read()) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("vpcSet/item", targetDepth)) { response.Vpcs.Add(VpcUnmarshaller.GetInstance().Unmarshall(context)); continue; } } } return response; }
public void GetVpcs_Ok() { // Arrange var vpcs = new List<Vpc> {new Vpc()}; var response = new DescribeVpcsResponse { Vpcs = vpcs }; Ec2ClientMock.Setup(x => x.DescribeVpcs(It.IsAny<DescribeVpcsRequest>())).Returns(response); // Act var actualVpcs = NetworkService.GetVpcs(); // Assert actualVpcs.Should().BeSameAs(vpcs); }