Пример #1
0
 /**
  * Creates object from $parsedResponse.
  * 
  * @param array $parsedResponse XML response parsed into array.
  * 
  * @return WindowsAzure\Common\Models\Metrics
  */
 public static function create($parsedResponse)
 {
     $result = new Metrics();
     $result->setVersion($parsedResponse['Version']);
     $result->setEnabled(Utilities::toBoolean($parsedResponse['Enabled']));
     if ($result->getEnabled()) {
         $result->setIncludeAPIs(Utilities::toBoolean($parsedResponse['IncludeAPIs']));
     }
     $result->setRetentionPolicy(RetentionPolicy::create($parsedResponse['RetentionPolicy']));
     return $result;
 }
 public function testCheckMetrics()
 {
     // Check that the default values of options are reasonable
     $rp = new RetentionPolicy();
     $m = new Metrics();
     $this->assertNull($m->getRetentionPolicy(), 'Default Metrics->getRetentionPolicy should be null');
     $this->assertNull($m->getVersion(), 'Default Metrics->getVersion should be null');
     $this->assertNull($m->getEnabled(), 'Default Metrics->getEnabled should be false');
     $this->assertNull($m->getIncludeAPIs(), 'Default Metrics->getIncludeAPIs should be null');
     $m->setRetentionPolicy($rp);
     $m->setVersion('2.0');
     $m->setEnabled(true);
     $m->setIncludeAPIs(true);
     $this->assertEquals($rp, $m->getRetentionPolicy(), 'Set Metrics->getRetentionPolicy');
     $this->assertEquals('2.0', $m->getVersion(), 'Set Metrics->getVersion');
     $this->assertTrue($m->getEnabled(), 'Set Metrics->getEnabled should be true');
     $this->assertTrue($m->getIncludeAPIs(), 'Set Metrics->getIncludeAPIs should be true');
 }
Пример #3
0
 /**
  * @covers WindowsAzure\Common\Models\Metrics::setEnabled
  */
 public function testSetEnabled()
 {
     // Setup
     $sample = TestResources::getServicePropertiesSample();
     $metrics = new Metrics();
     $expected = Utilities::toBoolean($sample['Metrics']['Enabled']);
     // Test
     $metrics->setEnabled($expected);
     // Assert
     $actual = $metrics->getEnabled();
     $this->assertEquals($expected, $actual);
 }