コード例 #1
0
 public void TestGetValueThrows()
 {
     Private.QuantityMetricType quantityMetric = new Private.QuantityMetricType(
         category: "telemetry",
         disabled: true,
         lifetime: Private.Lifetime.Application,
         name: "quantity_metric",
         sendInPings: new string[] { "store1" }
         );
     Assert.Throws <NullReferenceException>(() => quantityMetric.TestGetValue());
 }
コード例 #2
0
        public void DisabledCountersMustNotRecordData()
        {
            Private.QuantityMetricType quantityMetric = new Private.QuantityMetricType(
                category: "telemetry",
                disabled: true,
                lifetime: Private.Lifetime.Application,
                name: "quantity_metric",
                sendInPings: new string[] { "store1" }
                );

            // Attempt to store the quantity.
            quantityMetric.Set(1);
            // Check that nothing was recorded.
            Assert.False(quantityMetric.TestHasValue(), "Quantities must not be recorded if they are disabled");
        }
コード例 #3
0
        public void NegativeValuesAreNotRecorded()
        {
            Private.QuantityMetricType quantityMetric = new Private.QuantityMetricType(
                category: "telemetry",
                disabled: false,
                lifetime: Private.Lifetime.Application,
                name: "quantity_metric",
                sendInPings: new string[] { "store1" }
                );

            quantityMetric.Set(-10);
            // Check that quantity was NOT recorded.
            Assert.False(quantityMetric.TestHasValue("store1"));
            Assert.Equal(1, quantityMetric.TestGetNumRecordedErrors(ErrorType.InvalidValue));
        }
コード例 #4
0
        public void APISavesToSecondaryPings()
        {
            Private.QuantityMetricType quantityMetric = new Private.QuantityMetricType(
                category: "telemetry",
                disabled: false,
                lifetime: Private.Lifetime.Application,
                name: "quantity_metric",
                sendInPings: new string[] { "store1", "store2" }
                );

            quantityMetric.Set(1);

            // Check that the metric was properly recorded for the secondary ping.
            Assert.True(quantityMetric.TestHasValue("store2"));
            Assert.Equal(1, quantityMetric.TestGetValue("store2"));

            quantityMetric.Set(10);
            // Check that the metric was properly overwritten for the secondary ping.
            Assert.True(quantityMetric.TestHasValue("store2"));
            Assert.Equal(10, quantityMetric.TestGetValue("store2"));
        }