public void Reasons_SessionWithTutoringTrue_TutoringVisitCountIsOne() { var sessions = new List <Session>() { new Session() { InTime = new DateTime(2020, 12, 24, 10, 0, 0), OutTime = new DateTime(2020, 12, 24, 11, 00, 0), Tutoring = true, Person = new Person() { PersonType = PersonType.Student, Email = "*****@*****.**", FirstName = "Student", LastName = "One", Id = 12345 }, SessionClasses = new List <SessionClass>() { new SessionClass() { Class = new Class() { Name = "Art 101", CRN = 123, ShortName = "Art", DepartmentCode = 111 } } } } }; var results = ReportsBusinessLogic.Reasons(sessions, new DateTime(2020, 12, 24), new DateTime(2020, 12, 30)); Assert.Equal(1, results.Where(x => x.ReasonName == "Tutoring").FirstOrDefault().Visits); }
public void Reasons_SessionOnEndDay_ResultCountShouldBeOne() { var sessions = new List <Session>() { new Session() { InTime = new DateTime(2020, 12, 30, 10, 0, 0), OutTime = new DateTime(2020, 12, 30, 11, 00, 0), Tutoring = false, Person = new Person() { PersonType = PersonType.Student, Email = "*****@*****.**", FirstName = "Student", LastName = "One", Id = 12345 }, SessionClasses = new List <SessionClass>() { new SessionClass() { Class = new Class() { Name = "Art 101", CRN = 123, ShortName = "Art", DepartmentCode = 111 } } }, SessionReasons = new List <SessionReason>() { new SessionReason() { Reason = new Reason() { Name = "Study Time", Deleted = false } } } } }; var results = ReportsBusinessLogic.Reasons(sessions, new DateTime(2020, 12, 24), new DateTime(2020, 12, 30)); Assert.Single(results); }
public void Reasons_SessionWithClassSelectedAndStudyTimeSelected_TutoringIsFalse_VisitsForStudyTimeShouldBeOne() { var sessions = new List <Session>() { new Session() { InTime = new DateTime(2020, 12, 30, 10, 0, 0), OutTime = new DateTime(2020, 12, 30, 11, 00, 0), Tutoring = false, Person = new Person() { PersonType = PersonType.Student, Email = "*****@*****.**", FirstName = "Student", LastName = "One", Id = 12345 }, SessionClasses = new List <SessionClass>() { new SessionClass() { Class = new Class() { Name = "Art 101", CRN = 123, ShortName = "Art", DepartmentCode = 111 } } }, SessionReasons = new List <SessionReason>() { new SessionReason() { Reason = new Reason() { Name = "Study Time", Deleted = false } } } } }; var results = ReportsBusinessLogic.Reasons(sessions, new DateTime(2020, 12, 24), new DateTime(2020, 12, 30)); Assert.Equal(1, results.Where(x => x.ReasonName == "Study Time").FirstOrDefault().Visits); }
public void Reasons_TwoSessionsForAClass_TutoringIsTrue_TwoDifferentReasonsForVisit_ResultsIncludesClassFourTimes_OnceForEachReason() { var sessions = new List <Session>() { new Session() { InTime = new DateTime(2020, 12, 24, 10, 0, 0), OutTime = new DateTime(2020, 12, 24, 11, 00, 0), Tutoring = true, Person = new Person() { PersonType = PersonType.Student, Email = "*****@*****.**", FirstName = "Student", LastName = "One", Id = 12345 }, SessionClasses = new List <SessionClass>() { new SessionClass() { Class = new Class() { Name = "Art 101", CRN = 123, ShortName = "Art", DepartmentCode = 111 } } }, SessionReasons = new List <SessionReason>() { new SessionReason() { Reason = new Reason() { Name = "Study Time", Deleted = false } } } }, new Session() { InTime = new DateTime(2020, 12, 24, 10, 0, 0), OutTime = new DateTime(2020, 12, 24, 11, 00, 0), Tutoring = true, Person = new Person() { PersonType = PersonType.Student, Email = "*****@*****.**", FirstName = "Student", LastName = "One", Id = 12345 }, SessionClasses = new List <SessionClass>() { new SessionClass() { Class = new Class() { Name = "Art 101", CRN = 123, ShortName = "Art", DepartmentCode = 111 } } }, SessionReasons = new List <SessionReason>() { new SessionReason() { Reason = new Reason() { Name = "Printer Use", Deleted = false } } } }, }; var results = ReportsBusinessLogic.Reasons(sessions, new DateTime(2020, 12, 24), new DateTime(2020, 12, 30)); Assert.Equal(3, results.Where(x => x.ClassName == "Art 101").Count()); Assert.Equal(2, results.Where(x => x.ReasonName == "Tutoring").FirstOrDefault().Visits); }
public IActionResult Reasons([FromQuery] DateTime start, [FromQuery] DateTime end) { return(Ok(ReportsBusinessLogic.Reasons(_sessionRepo.GetAll(), start, end))); }