Esempio n. 1
0
        public void TestNumericImmutableMetricEqualityFunction()
        {
            const double dValue = 5.0;
            const long lValue = 6;
            const string name = "testname";
            const string desc = "testdesc";
            IMetricsInfo info = new MetricsInfoImpl(name, desc);

            ImmutableMetricsImpl metric = new ImmutableMetricsImpl(info,
                dValue,
                MetricType.Counter,
                (metricsVisitor) => { });

            ImmutableMetricsImpl otherMetric = new ImmutableMetricsImpl(info,
                dValue,
                MetricType.Counter,
                (metricsVisitor) => { });
            Assert.True(metric.Equals(otherMetric));
            otherMetric = new ImmutableMetricsImpl(info, lValue, MetricType.Counter, (metricsVisitor) => { });
            Assert.False(metric.Equals(otherMetric));
            otherMetric = new ImmutableMetricsImpl(new MetricsInfoImpl("wrongname", desc),
                dValue,
                MetricType.Counter,
                (metricsVisitor) => { });
            Assert.False(metric.Equals(otherMetric));
            otherMetric = new ImmutableMetricsImpl(new MetricsInfoImpl(name, "wrongdesc"),
                dValue,
                MetricType.Counter,
                (metricsVisitor) => { });
            Assert.False(metric.Equals(otherMetric));
            otherMetric = new ImmutableMetricsImpl(info, dValue, MetricType.Gauge, (metricsVisitor) => { });
            Assert.False(metric.Equals(otherMetric));
        }
Esempio n. 2
0
        public void TestLongImmutableMetricProperties()
        {
            const long lValue = 6;
            const string name = "testname";
            const string desc = "testdesc";
            IMetricsInfo info = new MetricsInfoImpl(name, desc);

            var metric = new ImmutableMetricsImpl(info, lValue, MetricType.Counter, (metricsVisitor) => { });
            Assert.Equal(metric.Info.Name, name);
            Assert.Equal(metric.Info.Description, desc);
            Assert.False(metric.NumericValue != null);
            Assert.Equal(metric.LongValue, lValue);
            Assert.Equal(metric.TypeOfMetric, MetricType.Counter);
        }
Esempio n. 3
0
        public void TestLongImmutableMetricToStringFunction()
        {
            const long lValue = 6;
            const string name = "testname";
            const string desc = "testdesc";
            IMetricsInfo info = new MetricsInfoImpl(name, desc);

            string expectedLongString = string.Format("Metric Type: {0}, Metric Information: {1}, Metric Value: {2}",
                MetricType.Counter,
                info,
                lValue);

            ImmutableMetricsImpl metric = new ImmutableMetricsImpl(info,
                lValue,
                MetricType.Counter,
                (metricsVisitor) => { });
            Assert.Equal(metric.ToString(), expectedLongString);
        }