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)); }
public void TestMetricsRecord() { const string name = "recname"; const string desc = "rec desc"; const long timeStamp = 1000; const string context = "context"; const string counterName = "counter"; const long counterValue = 2; const string gaugeName = "gauge"; const double gaugeValue = 3.0; const string tagName = "tagName"; const string tagValue = "tagValue"; IList <IImmutableMetric> metrics = new List <IImmutableMetric>(); metrics.Add(new ImmutableCounter(new MetricsInfoImpl(counterName, counterName), counterValue)); metrics.Add(new ImmutableDoubleGauge(new MetricsInfoImpl(gaugeName, gaugeName), gaugeValue)); IList <MetricsTag> tags = new List <MetricsTag>(); tags.Add(new MetricsTag(new MetricsInfoImpl(tagName, tagName), tagValue)); MetricsInfoImpl info = new MetricsInfoImpl(name, desc); MetricsRecord record = new MetricsRecord(info, timeStamp, metrics, tags, context); Assert.Equal(name, record.Name); Assert.Equal(desc, record.Description); Assert.Equal(context, record.Context); Assert.Equal(timeStamp, record.Timestamp); Assert.Equal(metrics, record.Metrics); Assert.Equal(tags, record.Tags); }
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); }
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); }
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); }
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()); }