public void CannotSetPayloadExtensionWithoutAddingItFirst()
        {
            using (var hbeat = new HeartbeatProvider())
            {
                hbeat.Initialize(configuration: null);

                Assert.IsFalse(hbeat.SetHeartbeatProperty("test01", "some other test value", true));
                Assert.IsTrue(hbeat.AddHeartbeatProperty("test01", "some test value", true));
                Assert.IsTrue(hbeat.SetHeartbeatProperty("test01", "some other test value", true));
            }
        }
Example #2
0
        public void CannotSetValueOfDefaultPayloadProperties()
        {
            using (var hbeat = new HeartbeatProvider())
            {
                hbeat.Initialize(configuration: null);

                foreach (string key in HeartbeatDefaultPayload.DefaultFields)
                {
                    Assert.IsFalse(hbeat.SetHeartbeatProperty(key, "test", true));
                }
            }
        }
        public void CanSetHealthHeartbeatPayloadValueWithoutHealthyFlag()
        {
            using (var hbeat = new HeartbeatProvider())
            {
                hbeat.Initialize(configuration: null);

                string key = "setValueTest";

                Assert.IsTrue(hbeat.AddHeartbeatProperty(key, "value01", true));
                Assert.IsTrue(hbeat.SetHeartbeatProperty(key, "value02"));
                var msg = (MetricTelemetry)hbeat.GatherData();

                Assert.IsNotNull(msg);
                Assert.IsTrue(msg.Properties.ContainsKey(key));
                Assert.IsTrue(msg.Properties[key].Equals("value02", StringComparison.Ordinal));
            }
        }
        public void CanSetHealthHeartbeatPayloadHealthIndicatorWithoutSettingValue()
        {
            using (var hbeat = new HeartbeatProvider())
            {
                hbeat.Initialize(configuration: null);

                string key = "healthSettingTest";

                Assert.IsTrue(hbeat.AddHeartbeatProperty(key, "value01", true));
                Assert.IsTrue(hbeat.SetHeartbeatProperty(key, null, false));
                var msg = (MetricTelemetry)hbeat.GatherData();

                Assert.IsNotNull(msg);
                Assert.IsTrue(msg.Properties.ContainsKey(key));
                Assert.IsTrue(msg.Properties[key].Equals("value01", StringComparison.Ordinal));
                Assert.IsTrue(msg.Sum == 1.0); // one false message in payload only
            }
        }