コード例 #1
0
        public void GetReportsFromDateReportstInDB_SpecificDate_NoErrorDetected()
        {
            //Arrange
            var reportList = new List <WeatherRepport>();

            reportList.Add(new WeatherRepport {
                AirPressure = 5, Humidity = 3, Id = 1, Place = new Place(), PlaceId = 1, Temp = 10, Time = DateTime.Now
            });
            reportList.Add(new WeatherRepport {
                AirPressure = 6, Humidity = 4, Id = 2, Place = new Place(), PlaceId = 2, Temp = 11, Time = DateTime.Now
            });
            reportList.Add(new WeatherRepport {
                AirPressure = 7, Humidity = 5, Id = 3, Place = new Place(), PlaceId = 3, Temp = 12, Time = DateTime.Now
            });

            DateDto dt = new DateDto();

            dt.StartDate = "Dec 29, 2020";
            dt.EndDate   = "Dec 31, 2020";


            databaseController.GetReportsBetweenTwoDates(DateTime.Parse(dt.StartDate), DateTime.Parse(dt.EndDate)).Returns(reportList);


            //Act
            var result = (_uut.getReportsBetweenTwoDates(dt).Result.Result as CreatedResult);

            //Assert

            Assert.That(result.StatusCode, Is.EqualTo(201));
        }
コード例 #2
0
        public async Task <ActionResult <List <WeatherRepport> > > getReportsBetweenTwoDates([FromBody] DateDto dates)
        {
            var compareStartDate = DateTime.Parse(dates.StartDate);
            var compareEndDate   = DateTime.Parse(dates.EndDate);

            var WRepotrs = _dbController.GetReportsBetweenTwoDates(compareStartDate, compareEndDate);

            if (WRepotrs == null)
            {
                return(NotFound());
            }
            else
            {
                return(Created(WRepotrs.ToString(), WRepotrs));
            }
        }