public virtual void TestFields()
        {
            TestMetricsAnnotations.MyMetrics metrics = new TestMetricsAnnotations.MyMetrics();
            MetricsSource source = MetricsAnnotations.MakeSource(metrics);

            metrics.c1.Incr();
            metrics.c2.Incr();
            metrics.g1.Incr();
            metrics.g2.Incr();
            metrics.g3.Incr();
            metrics.r1.Add(1);
            metrics.s1.Add(1);
            metrics.rs1.Add("rs1", 1);
            MetricsRecordBuilder rb = MetricsAsserts.GetMetrics(source);

            Org.Mockito.Mockito.Verify(rb).AddCounter(Interns.Info("C1", "C1"), 1);
            Org.Mockito.Mockito.Verify(rb).AddCounter(Interns.Info("Counter2", "Counter2 desc"
                                                                   ), 1L);
            Org.Mockito.Mockito.Verify(rb).AddGauge(Interns.Info("G1", "G1"), 1);
            Org.Mockito.Mockito.Verify(rb).AddGauge(Interns.Info("G2", "G2"), 1);
            Org.Mockito.Mockito.Verify(rb).AddGauge(Interns.Info("G3", "g3 desc"), 1L);
            Org.Mockito.Mockito.Verify(rb).AddCounter(Interns.Info("R1NumOps", "Number of ops for r1"
                                                                   ), 1L);
            Org.Mockito.Mockito.Verify(rb).AddGauge(Interns.Info("R1AvgTime", "Average time for r1"
                                                                 ), 1.0);
            Org.Mockito.Mockito.Verify(rb).AddCounter(Interns.Info("S1NumOps", "Number of ops for s1"
                                                                   ), 1L);
            Org.Mockito.Mockito.Verify(rb).AddGauge(Interns.Info("S1AvgTime", "Average time for s1"
                                                                 ), 1.0);
            Org.Mockito.Mockito.Verify(rb).AddCounter(Interns.Info("Rs1NumOps", "Number of ops for rs1"
                                                                   ), 1L);
            Org.Mockito.Mockito.Verify(rb).AddGauge(Interns.Info("Rs1AvgTime", "Average time for rs1"
                                                                 ), 1.0);
        }
        public virtual void TestClasses()
        {
            MetricsRecordBuilder rb = MetricsAsserts.GetMetrics(MetricsAnnotations.MakeSource
                                                                    (new TestMetricsAnnotations.MyMetrics3()));
            MetricsCollector collector = rb.Parent();

            Org.Mockito.Mockito.Verify(collector).AddRecord(Interns.Info("MyMetrics3", "My metrics"
                                                                         ));
            Org.Mockito.Mockito.Verify(rb).Add(Interns.Tag(MsInfo.Context, "foo"));
        }
        public virtual void TestMethods()
        {
            TestMetricsAnnotations.MyMetrics2 metrics = new TestMetricsAnnotations.MyMetrics2
                                                            ();
            MetricsSource        source = MetricsAnnotations.MakeSource(metrics);
            MetricsRecordBuilder rb     = MetricsAsserts.GetMetrics(source);

            Org.Mockito.Mockito.Verify(rb).AddGauge(Interns.Info("G1", "G1"), 1);
            Org.Mockito.Mockito.Verify(rb).AddGauge(Interns.Info("G2", "G2"), 2L);
            Org.Mockito.Mockito.Verify(rb).AddGauge(Interns.Info("G3", "G3"), 3.0f);
            Org.Mockito.Mockito.Verify(rb).AddGauge(Interns.Info("G4", "G4"), 4.0);
            Org.Mockito.Mockito.Verify(rb).AddCounter(Interns.Info("C1", "C1"), 1);
            Org.Mockito.Mockito.Verify(rb).AddCounter(Interns.Info("C2", "C2"), 2L);
            Org.Mockito.Mockito.Verify(rb).Tag(Interns.Info("T1", "T1"), "t1");
        }
        public virtual void TestHybrid()
        {
            TestMetricsAnnotations.HybridMetrics metrics = new TestMetricsAnnotations.HybridMetrics
                                                               ();
            MetricsSource source = MetricsAnnotations.MakeSource(metrics);

            NUnit.Framework.Assert.AreSame(metrics, source);
            metrics.C0.Incr();
            MetricsRecordBuilder rb        = MetricsAsserts.GetMetrics(source);
            MetricsCollector     collector = rb.Parent();

            Org.Mockito.Mockito.Verify(collector).AddRecord("foo");
            Org.Mockito.Mockito.Verify(collector).AddRecord("bar");
            Org.Mockito.Mockito.Verify(collector).AddRecord(Interns.Info("HybridMetrics", "HybridMetrics"
                                                                         ));
            Org.Mockito.Mockito.Verify(rb).SetContext("foocontext");
            Org.Mockito.Mockito.Verify(rb).AddCounter(Interns.Info("C1", "C1 desc"), 1);
            Org.Mockito.Mockito.Verify(rb).SetContext("barcontext");
            Org.Mockito.Mockito.Verify(rb).AddGauge(Interns.Info("G1", "G1 desc"), 1);
            Org.Mockito.Mockito.Verify(rb).Add(Interns.Tag(MsInfo.Context, "hybrid"));
            Org.Mockito.Mockito.Verify(rb).AddCounter(Interns.Info("C0", "C0 desc"), 1);
            Org.Mockito.Mockito.Verify(rb).AddGauge(Interns.Info("G0", "G0"), 0);
        }
 public virtual void TestBadFields()
 {
     MetricsAnnotations.MakeSource(new TestMetricsAnnotations.BadMetrics());
 }
 public virtual void TestEmptyMetrics()
 {
     MetricsAnnotations.MakeSource(new TestMetricsAnnotations.EmptyMetrics());
 }
 public virtual void TestBadMethodReturnType()
 {
     MetricsAnnotations.MakeSource(new TestMetricsAnnotations.BadMetrics3());
 }
 public virtual void TestBadMethodWithArgs()
 {
     MetricsAnnotations.MakeSource(new TestMetricsAnnotations.BadMetrics2());
 }