示例#1
0
 public void TestGetValueThrows()
 {
     Private.StringMetricType stringMetric = new Private.StringMetricType(
         category: "telemetry",
         disabled: true,
         lifetime: Private.Lifetime.Application,
         name: "string_metric",
         sendInPings: new string[] { "store1" }
         );
     Assert.Throws <NullReferenceException>(() => stringMetric.TestGetValue());
 }
示例#2
0
        public void SettingALongStringRecordsAnError()
        {
            Private.StringMetricType stringMetric = new Private.StringMetricType(
                category: "telemetry",
                disabled: false,
                lifetime: Private.Lifetime.Application,
                name: "string_metric",
                sendInPings: new string[] { "store1", "store2" }
                );

            stringMetric.Set(new string('3', 110));

            Assert.Equal(1, stringMetric.TestGetNumRecordedErrors(ErrorType.InvalidOverflow));
        }
示例#3
0
        public void DisabledstringsMustNotRecordData()
        {
            Private.StringMetricType stringMetric = new Private.StringMetricType(
                category: "telemetry",
                disabled: true,
                lifetime: Private.Lifetime.Application,
                name: "string_metric",
                sendInPings: new string[] { "store1" }
                );

            // Attempt to store the string.
            stringMetric.Set("value");
            // Check that nothing was recorded.
            Assert.False(stringMetric.TestHasValue(), "Strings must not be recorded if they are disabled");
        }
示例#4
0
        public void APISavesToSecondaryPings()
        {
            Private.StringMetricType stringMetric = new Private.StringMetricType(
                category: "telemetry",
                disabled: false,
                lifetime: Private.Lifetime.Application,
                name: "string_metric",
                sendInPings: new string[] { "store1", "store2" }
                );

            // Record two strings of the same type, with a little delay.
            stringMetric.Set("value");

            // Check that data was properly recorded in the second ping.
            Assert.True(stringMetric.TestHasValue("store2"));
            Assert.Equal("value", stringMetric.TestGetValue("store2"));

            stringMetric.Set("overriddenValue");
            // Check that data was properly recorded in the second ping.
            Assert.True(stringMetric.TestHasValue("store2"));
            Assert.Equal("overriddenValue", stringMetric.TestGetValue("store2"));
        }