Exemplo n.º 1
0
        public void TestFlowReportInactive()
        {
            var rep = new StatementMetricArray("uri", "name", 3, true);

            Assert.AreEqual(0, rep.AddStatementGetIndex("001"));
            Assert.AreEqual(1, rep.AddStatementGetIndex("002"));
            Assert.AreEqual(2, rep.AddStatementGetIndex("003"));
            rep.RemoveStatement("002");

            StatementMetric[] flushed = rep.FlushMetrics();
            for (int i = 0; i < 3; i++)
            {
                Assert.IsNotNull(flushed[i]);
            }
        }
Exemplo n.º 2
0
        public void TestFlowReportActive()
        {
            var rep = new StatementMetricArray("uri", "name", 3, false);

            Assert.AreEqual(0, rep.SizeLastElement);

            Assert.AreEqual(0, rep.AddStatementGetIndex("001"));
            Assert.AreEqual(1, rep.SizeLastElement);

            Assert.AreEqual(1, rep.AddStatementGetIndex("002"));
            Assert.AreEqual(2, rep.AddStatementGetIndex("003"));
            Assert.AreEqual(3, rep.SizeLastElement);

            rep.RemoveStatement("002");

            Assert.AreEqual(3, rep.AddStatementGetIndex("004"));
            Assert.AreEqual(4, rep.AddStatementGetIndex("005"));

            rep.RemoveStatement("005");
            Assert.AreEqual(5, rep.AddStatementGetIndex("006"));

            var metrics = new StatementMetric[6];

            for (int i = 0; i < 6; i++)
            {
                metrics[i] = rep.GetAddMetric(i);
            }

            StatementMetric[] flushed = rep.FlushMetrics();
            ArrayAssertionUtil.AssertSameExactOrder(metrics, flushed);

            Assert.AreEqual(1, rep.AddStatementGetIndex("007"));
            Assert.AreEqual(4, rep.AddStatementGetIndex("008"));

            rep.RemoveStatement("001");
            rep.RemoveStatement("003");
            rep.RemoveStatement("004");
            rep.RemoveStatement("006");
            rep.RemoveStatement("007");
            Assert.AreEqual(6, rep.SizeLastElement);
            rep.RemoveStatement("008");
            Assert.AreEqual(6, rep.SizeLastElement);

            flushed = rep.FlushMetrics();
            Assert.AreEqual(6, flushed.Length);
            Assert.AreEqual(0, rep.SizeLastElement);

            flushed = rep.FlushMetrics();
            Assert.IsNull(flushed);
            Assert.AreEqual(0, rep.SizeLastElement);

            Assert.AreEqual(0, rep.AddStatementGetIndex("009"));
            Assert.AreEqual(1, rep.SizeLastElement);

            flushed = rep.FlushMetrics();
            Assert.AreEqual(6, flushed.Length);
            for (int i = 0; i < flushed.Length; i++)
            {
                Assert.IsNull(flushed[i]);
            }
            Assert.AreEqual(1, rep.SizeLastElement);
        }