/**
  * @covers WindowsAzure\ServiceManagement\Models\AffinityGroup::toArray
  * @covers WindowsAzure\ServiceManagement\Models\AffinityGroup::__construct
  */
 public function testSerialize()
 {
     // Setup
     $serializer = new XmlSerializer();
     $expected = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
     $expected .= '<CreateService xmlns="http://schemas.microsoft.com/windowsazure">' . "\n";
     $expected .= ' <Name>Name</Name>' . "\n";
     $expected .= ' <Label>Label</Label>' . "\n";
     $expected .= ' <Description>Description</Description>' . "\n";
     $expected .= ' <Location>Location</Location>' . "\n";
     $expected .= '</CreateService>' . "\n";
     $affinitygroup = new AffinityGroup();
     $affinitygroup->setName('Name');
     $affinitygroup->setLabel('Label');
     $affinitygroup->setLocation('Location');
     $affinitygroup->setDescription('Description');
     $affinitygroup->addSerializationProperty(XmlSerializer::ROOT_NAME, 'CreateService');
     // Test
     $actual = $affinitygroup->serialize($serializer);
     // Assert
     $this->assertEquals($expected, $actual);
 }
 /**
  * Creates a new affinity group for the specified subscription.
  * 
  * @param string                            $name     The affinity group name.
  * @param string                            $label    A base-64 encoded name for
  * the affinity group. The name can be up to 100 characters in length.
  * @param string                            $location The data center location
  * where the affinity group will be created. To list available locations, use 
  * the listLocations API.
  * @param Models\CreateAffinityGroupOptions $options  The optional parameters.
  * 
  * @return none
  * 
  * @see http://msdn.microsoft.com/en-us/library/windowsazure/gg715317.aspx
  */
 public function createAffinityGroup($name, $label, $location, $options = null)
 {
     Validate::isString($name, 'name');
     Validate::notNullOrEmpty($name, 'name');
     Validate::isString($label, 'label');
     Validate::notNullOrEmpty($label, 'label');
     Validate::isString($location, 'location');
     Validate::notNullOrEmpty($location, 'location');
     if (is_null($options)) {
         $options = new CreateAffinityGroupOptions();
     }
     $affinityGroup = new AffinityGroup();
     $affinityGroup->setName($name);
     $affinityGroup->setLabel($label);
     $affinityGroup->setLocation($location);
     $affinityGroup->setDescription($options->getDescription());
     $affinityGroup->addSerializationProperty(XmlSerializer::ROOT_NAME, 'CreateAffinityGroup');
     $context = new HttpCallContext();
     $context->setMethod(Resources::HTTP_POST);
     $context->setPath($this->_getAffinityGroupPath());
     $context->addStatusCode(Resources::STATUS_CREATED);
     $context->setBody($affinityGroup->serialize($this->dataSerializer));
     $context->addHeader(Resources::CONTENT_TYPE, Resources::XML_ATOM_CONTENT_TYPE);
     $this->sendContext($context);
 }