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()); }
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"); }
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)); }
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")); }