public void TestListMetrics() { ListMetricsResult result = Client.ListMetrics(new ListMetricsRequest()); bool seenDimensions = false; Assert.IsTrue(result.Metrics.Count > 0); foreach (Metric metric in result.Metrics) { AssertNotEmpty(metric.MetricName); AssertNotEmpty(metric.Namespace); foreach (Dimension dimension in metric.Dimensions) { seenDimensions = true; AssertNotEmpty(dimension.Name); AssertNotEmpty(dimension.Value); } } Assert.IsTrue(seenDimensions); if (!string.IsNullOrEmpty(result.NextToken)) { result = Client.ListMetrics(new ListMetricsRequest() { NextToken = result.NextToken }); Assert.IsTrue(result.Metrics.Count > 0); } }
public void BasicCRUD() { ListMetricsResult listResult = Client.ListMetrics(new ListMetricsRequest()); Assert.IsNotNull(listResult); if (listResult.NextToken != null && listResult.NextToken.Length > 0) { listResult = Client.ListMetrics(new ListMetricsRequest() { NextToken = listResult.NextToken }); Assert.IsTrue(listResult.Metrics.Count > 0); } GetMetricStatisticsRequest getMetricRequest = new GetMetricStatisticsRequest() { MetricName = "NetworkIn", Namespace = "AWS/EC2", StartTime = DateTime.Parse("2008-01-01T19:00:00+00:00"), EndTime = DateTime.Parse("2009-12-01T19:00:00+00:00"), Statistics = new List <string> { "Average" }, Unit = "Percent", Period = 42000, }; GetMetricStatisticsResult getMetricResult = Client.GetMetricStatistics(getMetricRequest); Assert.IsNotNull(getMetricResult); Assert.IsTrue(getMetricResult.Datapoints.Count >= 0); Assert.IsNotNull(getMetricResult.Label); }