Exemplo n.º 1
0
        public void Start_adds_task()
        {
            // Arrange
            const string RANDOM_TASK_NAME = "lksdjfsidfuslufsdif";

            // Act
            var metricInfo = new MetricInfo();
            metricInfo.Start(RANDOM_TASK_NAME);

            // Assert
            Assert.AreEqual(1, metricInfo.TimeDetails.Count);
            Assert.AreEqual(RANDOM_TASK_NAME, metricInfo.TimeDetails[0].Name);
        }
Exemplo n.º 2
0
        public void default_ctor_defaults()
        {
            // Arrange

            // Act
            var metricInfo = new MetricInfo();

            // Assert
            Assert.IsNull(metricInfo.Name);
            Assert.IsNotNull(metricInfo.TimeDetails);
            Assert.IsNotNull(metricInfo.SummaryMessage);
            Assert.AreEqual(0.0d, metricInfo.TotalTimeInSeconds);
            Assert.AreEqual(0.0d, metricInfo.Duration);
        }
Exemplo n.º 3
0
        public void Start_Stop_creates_one_task_with_duration()
        {
            // Arrange
            const string RANDOM_TASK_NAME = "cxiuvbyvcxiubt";

            // Act
            var metricInfo = new MetricInfo();
            metricInfo.Start(RANDOM_TASK_NAME);
            Thread.Sleep(31);
            metricInfo.Stop();

            // Assert
            Assert.AreEqual(1, metricInfo.TimeDetails.Count);
            Assert.AreEqual(RANDOM_TASK_NAME, metricInfo.TimeDetails[0].Name);
            Assert.LessOrEqual(.030, metricInfo.TimeDetails[0].Duration);
        }
Exemplo n.º 4
0
        public void name_ctor_defaults()
        {
            // Arrange
            const string TEST_NAME = "Test Name";

            // Act
            var metricInfo = new MetricInfo(TEST_NAME);

            // Assert
            Assert.AreEqual(TEST_NAME, metricInfo.Name);
            Assert.IsNotNull(metricInfo.TimeDetails);
            Assert.IsNotNull(metricInfo.SummaryMessage);
            Assert.IsTrue(metricInfo.SummaryMessage.Contains(TEST_NAME));
            Assert.AreEqual(0.0d, metricInfo.TotalTimeInSeconds);
            Assert.AreEqual(0.0d, metricInfo.Duration);
        }
Exemplo n.º 5
0
        public MetricInfo StartChildMetric(string metricName)
        {
            // Let waiting threads do their work
            Thread.Sleep(0);

            var metricInfo = new MetricInfo(metricName);
            TimeDetails.Add(metricInfo);

            return metricInfo;
        }
Exemplo n.º 6
0
 public void AddChildMetric(MetricInfo childMetricInfo)
 {
     TimeDetails.Add(childMetricInfo);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="metricName">name of the metric for reporting</param>
 public HiPerfMetric(string metricName)
 {
     _metricInfo = new MetricInfo(metricName);
 }
Exemplo n.º 8
0
 public HiPerfMetric()
 {
     _metricInfo = new MetricInfo();
 }
Exemplo n.º 9
0
        public void TotalTimeInSeconds_adds_up()
        {
            // Arrange
            var task1 = new TaskInfo("task1") {Duration = 13};
            var task2 = new TaskInfo("task2") {Duration = 27};

            // Act
            var metricInfo = new MetricInfo();
            metricInfo.TimeDetails.AddRange(new[] {task1, task2});

            // Assert
            Assert.AreEqual(40.0d, metricInfo.TotalTimeInSeconds);
            Assert.AreEqual(40.0d, metricInfo.Duration);
        }
Exemplo n.º 10
0
        public void SummaryMessage_assembled()
        {
            // Arrange
            var task1 = new TaskInfo("task1") { Duration = 13 };
            var task2 = new TaskInfo("task2") { Duration = 27 };

            // Act
            var metricInfo = new MetricInfo("TestMetric");
            metricInfo.TimeDetails.AddRange(new[] { task1, task2 });

            // Assert
            Assert.AreEqual("'TestMetric': Time = 40.0000 seconds", metricInfo.SummaryMessage);
        }