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

            _repository.Setup(a => a.GetMetricsFromTimeToTime(It.IsAny <DateTimeOffset>(), It.IsAny <DateTimeOffset>()))
            .Returns(returnList).Verifiable();
            //Act
            var result = (OkObjectResult)_controller.GetMetricsFromCluster(
                DateTimeOffset.FromUnixTimeSeconds(0),
                DateTimeOffset.FromUnixTimeSeconds(17000000000));
            var actualResult = (AllHddMetricsResponse)result.Value;

            //Assert
            _repository.Verify(repository => repository.GetMetricsFromTimeToTime(
                                   DateTimeOffset.FromUnixTimeSeconds(0),
                                   DateTimeOffset.FromUnixTimeSeconds(17000000000)),
                               Times.Once());
            _ = Assert.IsAssignableFrom <IActionResult>(result);
            for (int i = 0; i < returnList.Count; i++)
            {
                Assert.Equal(returnList[i].Id, actualResult.Metrics[i].Id);
                Assert.Equal(returnList[i].Value, actualResult.Metrics[i].Value);
                Assert.Equal(returnList[i].IdAgent, actualResult.Metrics[i].IdAgent);
            }
            _logger.Verify();
        }