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 TestMetricsTagClass()
        {
            const string name = "tagtest";
            const string otherName = "othertagtest";
            const string desc = "tagtestdesc";
            const string otherDesc = "othertagtestdesc";
            const string tagValue = "tagvalue";
            const string otherTagValue = "othertagvalue";
            IMetricsFactory factory = TangFactory.GetTang().NewInjector().GetInstance<IMetricsFactory>();

            IMetricsInfo info = new MetricsInfoImpl(name, desc);
            MetricsTag tag = factory.CreateTag(info, tagValue);

            Assert.Equal(name, tag.Name);
            Assert.Equal(desc, tag.Description);
            Assert.Equal(tagValue, tag.Value);

            MetricsTag sameTag = factory.CreateTag(info, tagValue);
            Assert.True(tag.Equals(sameTag));

            MetricsTag otherTag = factory.CreateTag(info, otherTagValue);
            Assert.False(tag.Equals(otherTag));

            otherTag = factory.CreateTag(new MetricsInfoImpl(otherName, desc), tagValue);
            Assert.False(tag.Equals(otherTag));

            otherTag = factory.CreateTag(new MetricsInfoImpl(name, otherDesc), otherTagValue);
            Assert.False(tag.Equals(otherTag));

            string expectedToString = "Tag Information: " + "Name: " + info.Name + ", Description: " + info.Description +
                                      ", Tag Value: " + tagValue;
            Assert.Equal(expectedToString, tag.ToString());
        }
Exemplo n.º 3
0
        public void TestMetricsInfoImpl()
        {
            const string name = "testname";
            const string desc = "testdesc";

            MetricsInfoImpl impl = new MetricsInfoImpl(name, desc);
            Assert.Equal(name, impl.Name);
            Assert.Equal(desc, impl.Description);
        }
Exemplo n.º 4
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.º 5
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);
        }