Exemplo 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));
        }
Exemplo 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);
        }
Exemplo n.º 3
0
        public void TestNumericImmutableMetricToStringFunction()
        {
            const double dValue = 5.0;
            const string name   = "testname";
            const string desc   = "testdesc";
            IMetricsInfo info   = new MetricsInfoImpl(name, desc);
            string       expectedDoubleString = string.Format("Metric Type: {0}, Metric Information: {1}, Metric Value: {2}",
                                                              MetricType.Counter,
                                                              info,
                                                              dValue);

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

            Assert.Equal(metric.ToString(), expectedDoubleString);
        }