Esempio n. 1
0
        public void MetricDirective_DefaultNameSpace_Returns_ValidJson()
        {
            MetricDirective metricDirective = new MetricDirective();

            string jsonString = JsonConvert.SerializeObject(metricDirective);

            Assert.Equal("{\"Namespace\":\"aws-embedded-metrics\",\"Metrics\":[],\"Dimensions\":[[]]}", jsonString);
        }
Esempio n. 2
0
        public void MetricDirective_PutMetric_Returns_ValidJson()
        {
            MetricDirective metricDirective = new MetricDirective();

            metricDirective.PutMetric("Time", 10);

            string jsonString = JsonConvert.SerializeObject(metricDirective);

            Assert.Equal("{\"Namespace\":\"aws-embedded-metrics\",\"Metrics\":[{\"Name\":\"Time\",\"Unit\":\"None\"}],\"Dimensions\":[[]]}", jsonString);
        }
Esempio n. 3
0
        public void MetricDirective_SetNameSpace_Returns_ValidJson()
        {
            MetricDirective metricDirective = new MetricDirective();

            metricDirective.Namespace = "test-lambda-metrics";

            string jsonString = JsonConvert.SerializeObject(metricDirective);

            Assert.Equal("{\"Namespace\":\"test-lambda-metrics\",\"Metrics\":[],\"Dimensions\":[[]]}", jsonString);
        }
Esempio n. 4
0
        public void MetricDirective_PutMultipleDimensions_Returns_ValidJson()
        {
            MetricDirective metricDirective = new MetricDirective();

            metricDirective.CustomDimensionSets.Add(new DimensionSet("Region", "US-West-2"));
            metricDirective.CustomDimensionSets.Add(new DimensionSet("Instance", "instance-1"));

            string jsonString = JsonConvert.SerializeObject(metricDirective);

            Assert.Equal("{\"Namespace\":\"aws-embedded-metrics\",\"Metrics\":[],\"Dimensions\":[[\"Region\",\"Instance\"]]}", jsonString);
        }
Esempio n. 5
0
        public void MetricDirective_PutSameMetricMultipleTimes_Returns_ValidValues()
        {
            MetricDirective metricDirective = new MetricDirective();

            metricDirective.PutMetric("Time", 10);
            metricDirective.PutMetric("Time", 20);

            Assert.Single(metricDirective.Metrics);
            Assert.Equal(new List <double>()
            {
                10, 20
            }, metricDirective.Metrics[0].Values);
        }
Esempio n. 6
0
        public void MetadataNode_IsSerialized_IfMetricsArePresent()
        {
            // arrange
            RootNode rootNode        = new RootNode();
            var      metricDirective = new MetricDirective();

            metricDirective.PutMetric("Metric", 1);
            rootNode.AWS.CloudWatchMetrics.Add(metricDirective);

            // act
            var json = JsonConvert.SerializeObject(rootNode);

            // assert
            Assert.Contains("_aws", json);
        }