public void GetRequestHistory_Retrieved_Success()
        {
            // Assert
            var history = new[]
            {
                new AirConditionUnitRequestDto
                {
                    AirConditionUnitId = AirConditionUnitId,
                    RequesterEmail     = "email",
                    Temperature        = 14,
                    Id             = 5,
                    UpdateDateTime = DateTime.UtcNow
                }
            };

            _repository.Get(AirConditionUnitId).Returns(history);

            // Act
            Result <TemperatureRequestHistory[]> result = _airConditionUnitService.GetRequestHistory(AirConditionUnitId);

            // Assert
            Assert.IsNotNull(result, Common.ShowResponseTypeMismatchMessage(typeof(Result <TemperatureRequestHistory[]>)));
            Assert.AreEqual(history.Length, result.ReturnObject.Length, Common.ShowNotSatisfiedExpectationMessage(1, "result.ReturnObject.Length"));
        }
示例#2
0
        public Result <TemperatureRequestHistory[]> GetRequestHistory(string airConditionUnitId)
        {
            AirConditionUnitRequestDto[] historyDto;

            try
            {
                historyDto = _repository.Get(airConditionUnitId);
            }
            catch (Exception e)
            {
                _logger.Error("Failed to retreive history", e);
                return(new Result <TemperatureRequestHistory[]>(ErrorCodeType.UnknownError));
            }

            var history = historyDto.Select(h => new TemperatureRequestHistory(h, AirFlowConstants.UkTimeZone)).ToArray();

            return(new Result <TemperatureRequestHistory[]>(history));
        }