Beispiel #1
0
        public void GetHddPercentileFromCluster()
        {
            //Arrange
            var fixture    = new Fixture();
            var returnList = fixture.Create <List <HddMetricModel> >();

            _repository.Setup(a => a.GetMetricsFromTimeToTimeOrderBy(It.IsAny <DateTimeOffset>(), It.IsAny <DateTimeOffset>(), "value"))
            .Returns(returnList).Verifiable();
            //Act
            var result = (OkObjectResult)_controller.GetMetricsByPercentileFromCluster(
                DateTimeOffset.FromUnixTimeSeconds(0),
                DateTimeOffset.FromUnixTimeSeconds(17000000000),
                Percentile.P90);

            //Assert
            _repository.Verify(repository => repository.GetMetricsFromTimeToTimeOrderBy(
                                   DateTimeOffset.FromUnixTimeSeconds(0),
                                   DateTimeOffset.FromUnixTimeSeconds(17000000000),
                                   "value"),
                               Times.Once());
            _ = Assert.IsAssignableFrom <IActionResult>(result);
            int percentileThisList = (int)Percentile.P90;

            percentileThisList = percentileThisList * returnList.Count / 100;

            var returnPercentile = returnList[percentileThisList].Value;

            Assert.Equal(returnPercentile, result.Value);
            _logger.Verify();
        }
        public void GetMetricsByPercentileFromClusterCheckRequestSelect()
        {
            //Arrange
            DateTimeOffset fromTime = DateTimeOffset.FromUnixTimeSeconds(3);
            DateTimeOffset toTime   = DateTimeOffset.FromUnixTimeSeconds(15);

            Percentile percentile = Percentile.P90;
            string     sort       = "value";

            _mock.Setup(a => a.GetByPeriodWithSorting(fromTime, toTime, sort))
            .Returns(new List <HddMetricModel>()).Verifiable();
            //Act
            var result = _controller.GetMetricsByPercentileFromCluster(fromTime, toTime, percentile);

            //Assert
            _mock.Verify(repository => repository.GetByPeriodWithSorting(fromTime, toTime, sort), Times.AtMostOnce());
            _logger.Verify();
        }