Ejemplo n.º 1
0
        public void IsTimePeriodValid_InvalidTimePeriod(string datefrom, string dateto)
        {
            // Arrange
            bool expectedResult = false;

            // Act
            bool result = TimePeriodValidator.IsDateFormatAndPeriodValid(datefrom, dateto);

            // Assert
            Assert.Equal(result, expectedResult);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> GetLogsFromTimePeriod(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req)
        {
            _dateFrom = req.Query["datefrom"];
            _dateTo   = req.Query["dateto"];

            if (!TimePeriodValidator.IsDateFormatAndPeriodValid(_dateFrom, _dateTo))
            {
                _log.Error($"Date from {_dateFrom} and or date to {_dateTo} was not not in correct format and" +
                           $" it was not possible to finish the action. Expected date format MM.dd.yyyy HH:mm:ss.");
                throw new InvalidDateFormatAndPeriodException();
            }

            List <LogEntity> returnedData = await _tableStorage.GetTableDataFromPeriod(_dateFrom, _dateTo);

            var mappedData = _mappings.MapReturnedDataToLog(returnedData);

            return(new OkObjectResult(mappedData));
        }