public void Should_Insert_Session_Without_Teacher_And_Users() { var options = new DbContextOptionsBuilder <RegistrationContext>() .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name) .Options; using (var context = new RegistrationContext(options)) { IRSSessionRepository sessionRepository = new SessionRepository(context); IRSCourseRepository courseRepository = new CourseRepository(context); var hugeCourse = new CourseTO() { Name = "Huge COurse" }; var addedCourse = courseRepository.Add(hugeCourse); var hugeSession = new SessionTO() { Course = addedCourse }; var addedSession = sessionRepository.Add(hugeSession); context.SaveChanges(); Assert.AreEqual(1, sessionRepository.GetAll().Count()); } }
public async Task <ActionResult <IEnumerable <SessionReadDto> > > GetAll() { var entities = await _repository.GetAll(); var readDtos = _mapper.Map <List <SessionReadDto> >(entities); return(readDtos); }
public void Repository_Session_deveria_buscar_todos_as_sessoes() { //Action var sessions = _repository.GetAll().ToList(); //Assert sessions.Should().NotBeNull(); sessions.Should().HaveCount(Context.Sessions.Count()); sessions.First().Should().Be(_sessionSeed); }
public void Sessions_Repository_Should_Get_All_Sucessfully() { //Action var sessions = _repository.GetAll().ToList(); //Assert sessions.Should().NotBeNull(); sessions.Should().HaveCount(_context.Sessions.Count()); sessions.First().Should().Be(_sessionBase); sessions.First().Lounge.Should().NotBeNull(); }
public void GetAllSessions_Call_NotFail_Test() { var context = new MyEventsContext(); int eventDefinitionId = context.Sessions.FirstOrDefault().EventDefinitionId; int expectedCount = context.Sessions.Count(q => q.EventDefinitionId == eventDefinitionId); ISessionRepository target = new SessionRepository(); IEnumerable <Session> results = target.GetAll(eventDefinitionId); Assert.IsNotNull(results); Assert.AreEqual(expectedCount, results.Count()); }
public void GetAllSessions_Call_CalculateScore_Test() { var context = new MyEventsContext(); int eventDefinitionId = context.Sessions.FirstOrDefault().EventDefinitionId; int expectedCount = context.Sessions.Count(q => q.EventDefinitionId == eventDefinitionId); ISessionRepository target = new SessionRepository(); IEnumerable<Session> results = target.GetAll(eventDefinitionId); Assert.IsNotNull(results); Assert.AreEqual(expectedCount, results.Count()); foreach (var session in results) ValidateScore(session.SessionId, session.Score); }
public void GetAllSessions_Call_CalculateScore_Test() { var context = new MyEventsContext(); int eventDefinitionId = context.Sessions.FirstOrDefault().EventDefinitionId; int expectedCount = context.Sessions.Count(q => q.EventDefinitionId == eventDefinitionId); ISessionRepository target = new SessionRepository(); IEnumerable <Session> results = target.GetAll(eventDefinitionId); Assert.IsNotNull(results); Assert.AreEqual(expectedCount, results.Count()); foreach (var session in results) { ValidateScore(session.SessionId, session.Score); } }
public void GetAllSessions_Call_NotFail_Test() { var context = new MyEventsContext(); int eventDefinitionId = context.Sessions.FirstOrDefault().EventDefinitionId; int expectedCount = context.Sessions.Count(q => q.EventDefinitionId == eventDefinitionId); ISessionRepository target = new SessionRepository(); IEnumerable<Session> results = target.GetAll(eventDefinitionId); Assert.IsNotNull(results); Assert.AreEqual(expectedCount, results.Count()); }
public void Should_Return_True_When_Item_Removed() { var options = new DbContextOptionsBuilder <RegistrationContext>() .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name) .Options; using (var context = new RegistrationContext(options)) { IRSUserRepository userRepository = new UserRepository(context); IRSSessionRepository sessionRepository = new SessionRepository(context); IRSCourseRepository courseRepository = new CourseRepository(context); var Teacher = new UserTO() { //Id = 420, Name = "Christian", Email = "*****@*****.**", Role = UserRole.Teacher }; var Michou = new UserTO() { //Id = 45, Name = "Michou Miraisin", Email = "*****@*****.**", Role = UserRole.Attendee }; var AddedTeacher = userRepository.Add(Teacher); var AddedAttendee = userRepository.Add(Michou); context.SaveChanges(); var SQLCourse = new CourseTO() { //Id = 28, Name = "SQL" }; var AddedCourse = courseRepository.Add(SQLCourse); context.SaveChanges(); var SQLSession = new SessionTO() { //Id = 1, Attendees = new List <UserTO>() { Michou }, Course = AddedCourse, Teacher = Teacher, }; var AddedSession = sessionRepository.Add(SQLSession); context.SaveChanges(); Assert.AreEqual(1, sessionRepository.GetAll().Count()); var RemovedSession = sessionRepository.Remove(1); context.SaveChanges(); Assert.AreEqual(0, sessionRepository.GetAll().Count()); } }
public IActionResult Index() { return(Json(_sessions.GetAll())); }
public void Should_Insert_Session_when_valid() { var options = new DbContextOptionsBuilder <RegistrationContext>() .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name) .Options; using (var context = new RegistrationContext(options)) { IRSUserRepository userRepository = new UserRepository(context); IRSSessionRepository sessionRepository = new SessionRepository(context); IRSCourseRepository courseRepository = new CourseRepository(context); var Teacher = new UserTO() { //Id = 420, Name = "Christian", Email = "*****@*****.**", Role = UserRole.Teacher }; var Michou = new UserTO() { //Id = 45, Name = "Michou Miraisin", Email = "*****@*****.**", Role = UserRole.Attendee }; var AddedTeacher = userRepository.Add(Teacher); var AddedAttendee = userRepository.Add(Michou); context.SaveChanges(); var SQLCourse = new CourseTO() { //Id = 28, Name = "SQL" }; var AddedCourse = courseRepository.Add(SQLCourse); context.SaveChanges(); var SQLSession = new SessionTO() { //Id = 1, Attendees = new List <UserTO>() { AddedAttendee }, Course = AddedCourse, Teacher = AddedTeacher, }; //By Amb //var mySession = new SessionTO() //{ // Attendees = new List<UserTO> { new UserTO { Name = "AAA", Email = "*****@*****.**", Role = UserRole.Attendee, IsActivated = false } }, //}; //By Amb var AddedSession = sessionRepository.Add(SQLSession); context.SaveChanges(); Assert.AreEqual(2, userRepository.GetAll().Count()); Assert.AreEqual(1, sessionRepository.GetAll().Count()); } }
public List <Session> AllSessions() { return(sessionRepo.GetAll()); }
public IList <Session> GetAllEventSessions(int eventId) { return(_sessionRepository.GetAll( d => d.EventId.Equals(eventId))); }
public List <Session> GetAll() { return(_sessionRepository.GetAll()); }