예제 #1
0
        public void PeakHours_SessionsWithinStartAndEndDate_2SessionsAt10AM_OneSessionAt5PM_ResultCountShouldBeTwo_10AMCountShouldBeTwo_5PMCountShouldBeOne()
        {
            var sessions = new List <Session>()
            {
                new Session()
                {
                    InTime  = new DateTime(2020, 12, 03, 10, 0, 0),
                    OutTime = new DateTime(2020, 12, 03, 11, 00, 0),
                },
                new Session()
                {
                    InTime  = new DateTime(2020, 12, 05, 10, 0, 0),
                    OutTime = new DateTime(2020, 12, 05, 11, 00, 0),
                },
                new Session()
                {
                    InTime  = new DateTime(2020, 12, 06, 17, 0, 0),
                    OutTime = new DateTime(2020, 12, 06, 17, 00, 0),
                }
            };

            var results = ReportsBusinessLogic.PeakHours(sessions, new DateTime(2020, 12, 01), new DateTime(2020, 12, 07));

            Assert.Equal(2, results.Count);
            Assert.Equal(2, results.Where(x => x.Hour == "10 A.M").FirstOrDefault().Count);
            Assert.Equal(1, results.Where(x => x.Hour == "5 P.M").FirstOrDefault().Count);
        }
예제 #2
0
        public void PeakHours_SessionOnEndDayAt10AM_ResultListShouldHaveOneElement_HourShouldBe10AM()
        {
            var sessions = new List <Session>()
            {
                new Session()
                {
                    InTime  = new DateTime(2020, 12, 07, 10, 0, 0),
                    OutTime = new DateTime(2020, 12, 07, 11, 00, 0),
                }
            };

            var results = ReportsBusinessLogic.PeakHours(sessions, new DateTime(2020, 12, 01), new DateTime(2020, 12, 07));

            Assert.Single(results);
            Assert.Equal(1, results.Where(x => x.Hour == "10 A.M").FirstOrDefault().Count);
        }
예제 #3
0
 public IActionResult PeakHours([FromQuery] DateTime start, [FromQuery] DateTime end)
 {
     return(Ok(ReportsBusinessLogic.PeakHours(_sessionRepo.GetAll(), start, end)));
 }