Contains the output of DescribeSubnets.
Inheritance: Amazon.Runtime.AmazonWebServiceResponse
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>  
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            DescribeSubnetsResponse response = new DescribeSubnetsResponse();

            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("subnetSet/item", targetDepth))
                    {
                        var unmarshaller = SubnetUnmarshaller.Instance;
                        var item = unmarshaller.Unmarshall(context);
                        response.Subnets.Add(item);
                        continue;
                    }
                } 
            }

            return response;
        }
        public void GetCidrBySubnet_Ok()
        {
            // Arrange
            const string subnetId = "SubnetOne";
            const string cidr = "192.0.0.0/24";
            var response = new DescribeSubnetsResponse {Subnets = new List<Subnet> {new Subnet {CidrBlock = "192.0.0.0/24"}}};
            Ec2ClientMock.Setup(x => x.DescribeSubnets(It.Is<DescribeSubnetsRequest>(req => req.SubnetIds.Contains("SubnetOne")))).Returns(response);

            // Act
            var results = NetworkService.GetCidrBySubnetId(subnetId);

            // Assert
            results.Should().Be(cidr);
        }
 public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) 
 {   
     DescribeSubnetsResponse response = new DescribeSubnetsResponse();
     
     int targetDepth = 2;
     while (context.Read())
     {
         if (context.IsStartElement || context.IsAttribute)
         {
             
             if (context.TestExpression("subnetSet/item", targetDepth))
             {
                 response.Subnets.Add(SubnetUnmarshaller.GetInstance().Unmarshall(context));
                     
                 continue;
             }
         }
     }
          
                 
     return response;
 }
        public void GetSubnetsByVpcId_Ok()
        {
            // Arrange
            const string vpcId = "VpcOne";
            var subnetInVpcOne = new Subnet {VpcId = vpcId};
            var subnetInVpcTwo = new Subnet {VpcId = "VpcTwo"};
            var subnets = new List<Subnet>
            {
                subnetInVpcOne,
                subnetInVpcTwo
            };
            var response = new DescribeSubnetsResponse {Subnets = subnets};
            Ec2ClientMock.Setup(x => x.DescribeSubnets(It.IsAny<DescribeSubnetsRequest>())).Returns(response);

            // Act
            var actualSubnets = NetworkService.GetSubnets(vpcId);

            // Assert
            actualSubnets.Single().Should().BeSameAs(subnetInVpcOne);
        }