public void Volunteers_TwoTeachersHaveOneHourSessions_EachTeachersHoursSummedCorrectly() { var sessions = new List <Session>() { new Session() { InTime = new DateTime(2020, 12, 05, 10, 0, 0), OutTime = new DateTime(2020, 12, 05, 11, 00, 0), Person = new Person() { FirstName = "Teacher", LastName = "Teach", Email = "*****@*****.**", PersonType = PersonType.Teacher } }, new Session() { InTime = new DateTime(2020, 12, 07, 10, 0, 0), OutTime = new DateTime(2020, 12, 07, 11, 00, 0), Person = new Person() { FirstName = "Teacher", LastName = "Teach", Email = "*****@*****.**", PersonType = PersonType.Teacher } }, }; var results = ReportsBusinessLogic.Volunteers(sessions, new DateTime(2020, 12, 01), new DateTime(2020, 12, 07)); Assert.Equal(1, results.Where(x => x.TeacherEmail == "*****@*****.**").FirstOrDefault().TotalHours); Assert.Equal(1, results.Where(x => x.TeacherEmail == "*****@*****.**").FirstOrDefault().TotalHours); }
public void Volunteers_SessionOnEndDay_ResultListShouldHaveOneElement() { 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), Person = new Person() { FirstName = "Teacher", LastName = "Teach", Email = "*****@*****.**", PersonType = PersonType.Teacher } } }; var results = ReportsBusinessLogic.Volunteers(sessions, new DateTime(2020, 12, 01), new DateTime(2020, 12, 07)); Assert.Single(results); }
public IActionResult Volunteers([FromQuery] DateTime start, [FromQuery] DateTime end) { return(Ok(ReportsBusinessLogic.Volunteers(_sessionRepo.GetAll(), start, end))); }