public virtual void TestContainerMetricsFlow()
        {
            string Err = "Error in number of records";
            // Create a dummy MetricsSystem
            MetricsSystem system = Org.Mockito.Mockito.Mock <MetricsSystem>();

            Org.Mockito.Mockito.DoReturn(this).When(system).Register(Matchers.AnyString(), Matchers.AnyString
                                                                         (), Matchers.Any());
            MetricsCollectorImpl collector   = new MetricsCollectorImpl();
            ContainerId          containerId = Org.Mockito.Mockito.Mock <ContainerId>();
            ContainerMetrics     metrics     = ContainerMetrics.ForContainer(containerId, 100, 1);

            metrics.RecordMemoryUsage(1024);
            metrics.GetMetrics(collector, true);
            NUnit.Framework.Assert.AreEqual(Err, 0, collector.GetRecords().Count);
            Sharpen.Thread.Sleep(110);
            metrics.GetMetrics(collector, true);
            NUnit.Framework.Assert.AreEqual(Err, 1, collector.GetRecords().Count);
            collector.Clear();
            Sharpen.Thread.Sleep(110);
            metrics.GetMetrics(collector, true);
            NUnit.Framework.Assert.AreEqual(Err, 1, collector.GetRecords().Count);
            collector.Clear();
            metrics.Finished();
            metrics.GetMetrics(collector, true);
            NUnit.Framework.Assert.AreEqual(Err, 1, collector.GetRecords().Count);
            collector.Clear();
            metrics.GetMetrics(collector, true);
            NUnit.Framework.Assert.AreEqual(Err, 0, collector.GetRecords().Count);
            Sharpen.Thread.Sleep(110);
            metrics.GetMetrics(collector, true);
            NUnit.Framework.Assert.AreEqual(Err, 0, collector.GetRecords().Count);
        }
        public virtual void TestContainerMetricsLimit()
        {
            string        Err    = "Error in number of records";
            MetricsSystem system = Org.Mockito.Mockito.Mock <MetricsSystem>();

            Org.Mockito.Mockito.DoReturn(this).When(system).Register(Matchers.AnyString(), Matchers.AnyString
                                                                         (), Matchers.Any());
            MetricsCollectorImpl collector   = new MetricsCollectorImpl();
            ContainerId          containerId = Org.Mockito.Mockito.Mock <ContainerId>();
            ContainerMetrics     metrics     = ContainerMetrics.ForContainer(containerId, 100, 1);
            int    anyPmemLimit = 1024;
            int    anyVmemLimit = 2048;
            int    anyVcores    = 10;
            string anyProcessId = "1234";

            metrics.RecordResourceLimit(anyVmemLimit, anyPmemLimit, anyVcores);
            metrics.RecordProcessId(anyProcessId);
            Sharpen.Thread.Sleep(110);
            metrics.GetMetrics(collector, true);
            NUnit.Framework.Assert.AreEqual(Err, 1, collector.GetRecords().Count);
            MetricsRecord record = collector.GetRecords()[0];

            MetricsRecords.AssertTag(record, ContainerMetrics.ProcessidInfo.Name(), anyProcessId
                                     );
            MetricsRecords.AssertMetric(record, ContainerMetrics.PmemLimitMetricName, anyPmemLimit
                                        );
            MetricsRecords.AssertMetric(record, ContainerMetrics.VmemLimitMetricName, anyVmemLimit
                                        );
            MetricsRecords.AssertMetric(record, ContainerMetrics.VcoreLimitMetricName, anyVcores
                                        );
            collector.Clear();
        }