public void Repository_Session_deveria_gravar_um_novo_sessao() { //Arrange Session result = _repository.Add(_session); result.Id.Should().BeGreaterThan(0); }
public void GetSessionExistentSessionShouldReturnSpecificTypeFromDB() { sessionRepositoryInMemory.Add(session); sessionRepositoryInMemory.SaveChanges(); Assert.AreEqual(sessionRepositoryInMemory.Get(session.Id), session); }
public void AddTest() { doctorRepository.Add(doctor); patientRepository.Add(patient); sessionrepository.Add(session); bool result = dbContext.SaveChanges() > 2; Assert.IsTrue(result); Transaction.Current.Rollback(); }
/// <summary> /// metoda dodania sesji do bazy /// </summary> /// <param name="addDataRequest"></param> /// <returns>zwracana odpowiedź czy udało się dodać sesję do bazy</returns> public AddSessionResponse AddSession(AddSessionRequest addDataRequest) { var response = new AddSessionResponse(); try { _unitOfWork.BeginTransaction(); var check = _repositoryBoat.IsExistBoat(addDataRequest.IdBoat); if (check) { Session session = Mapper.Map <Session>(addDataRequest); session.IdSession = Guid.NewGuid(); _repositorySession.Add(session); response.IdSession = session.IdSession; _unitOfWork.Commit(); response.IsSuccess = true; } else { _unitOfWork.Commit(); response.IsSuccess = false; response.ErrorMessage = "Łódki o takim id nie istnieje"; } } catch (Exception ex) { response.IsSuccess = false; response.ErrorMessage = ex.ToString(); } return(response); }
public void GetUserBySession_NoUserSession() { var options = new DbContextOptionsBuilder <RegistrationContext>() .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name) .Options; using var RSCxt = new RegistrationContext(options); IRSUserRepository userRepository = new UserRepository(RSCxt); IRSCourseRepository courseRepository = new CourseRepository(RSCxt); IRSSessionRepository sessionRepository = new SessionRepository(RSCxt); var Teacher = new UserTO() { Name = "Max", Email = "*****@*****.**", Role = UserRole.Teacher }; var Jack = new UserTO() { Name = "Jack Jack", Email = "*****@*****.**", Role = UserRole.Attendee }; var John = new UserTO() { Name = "John", Email = "*****@*****.**", Role = UserRole.Attendee }; var AddedUser0 = userRepository.Add(Teacher); var AddedUser1 = userRepository.Add(Jack); var AddedUser2 = userRepository.Add(John); RSCxt.SaveChanges(); var SQLCourse = new CourseTO() { Name = "SQL" }; var AddedCourse = courseRepository.Add(SQLCourse); RSCxt.SaveChanges(); var SQLSession = new SessionTO() { Attendees = new List <UserTO>() { }, Course = AddedCourse, Teacher = null }; var AddedSession = sessionRepository.Add(SQLSession); RSCxt.SaveChanges(); Assert.ThrowsException <NullReferenceException>(() => userRepository.GetUsersBySession(AddedSession)); }
public void AddSession_Added_NotFail_Test() { var context = new MyEventsContext(); int eventDefinitionId = context.EventDefinitions.FirstOrDefault().EventDefinitionId; int expected = context.Sessions.Count() + 1; ISessionRepository target = new SessionRepository(); Session session = new Session(); session.EventDefinitionId = eventDefinitionId; session.Title = Guid.NewGuid().ToString(); session.Description = Guid.NewGuid().ToString(); session.Speaker = Guid.NewGuid().ToString(); session.Biography = Guid.NewGuid().ToString(); session.TwitterAccount = Guid.NewGuid().ToString(); session.StartTime = DateTime.Now; session.TimeZoneOffset = 2; session.Duration = 60; target.Add(session); int actual = context.Sessions.Count(); Assert.AreEqual(expected, actual); }
public void AddSession_Added_NotFail_Test() { var context = new MyEventsContext(); int eventDefinitionId = context.EventDefinitions.FirstOrDefault().EventDefinitionId; int expected = context.Sessions.Count() + 1; ISessionRepository target = new SessionRepository(); Session session = new Session(); session.EventDefinitionId = eventDefinitionId; session.Title = Guid.NewGuid().ToString(); session.Description = Guid.NewGuid().ToString(); session.Speaker = Guid.NewGuid().ToString(); session.Biography = Guid.NewGuid().ToString(); session.TwitterAccount = Guid.NewGuid().ToString(); session.StartTime = DateTime.Now; session.TimeZoneOffset = 2; session.Duration = 60; target.Add(session); int actual = context.Sessions.Count(); Assert.AreEqual(expected, actual); }
public SessionModule() { Get["/sessions"] = parameters => { return(SessionRepository.All()); }; Get["/sessions/{id}"] = parameters => { return(SessionRepository.Single(parameters.id)); }; Post["/sessions"] = parameters => { Session item = this.Bind(); SessionRepository.Add(item); return(HttpStatusCode.Created); }; Put["/sessions/{id}"] = parameters => { Session item = SessionRepository.Single(parameters.id); this.BindTo(item, s => s.SessionID); SessionRepository.Update(item); return(HttpStatusCode.OK); }; Delete["/sessions/{id}"] = parameters => { SessionRepository.Delete(parameters.id); return(HttpStatusCode.NoContent); }; }
public object Post(RequestDTO.SessionRequest request) { return(SessionRepository.Add(new Session() { Name = request.Name, Speaker = request.Speaker, Room = request.Room })); }
private void AddSession(long entityId, IEnumerable <Change> changes) { // ensure that the entityId does NOT already exist in the Repository var session = SessionRepository.Get(entityId); if (session == null) { // this session does not exist - create it session = new Session() { SessionId = entityId }; foreach (var change in changes) { session.UpdateProperty(change.Key, change.Value); } SessionRepository.Add(session); ChangeLogProvider.SessionChangeLog.Add(new ProviderLogEntry { EntityId = session.SessionId, ActionType = ActionType.Add, EntityDisplay = session.Title }); } }
public int AddSession(Session input) { int result = CRUDStatusCode.ERROR; if (input != null) { var session = _SessionRepository.Get(t => t.Name == input.Name || t.Code == input.Code).FirstOrDefault(); if (session == null) { input.StatusId = CommonStatus.ACTIVE; input.CreateDate = Common.Utilities.GetServerDateTimeNow(); input.LastUpdateDate = Common.Utilities.GetServerDateTimeNow(); input.LastUpdateBy = Common.Session.GetId(); _SessionRepository.Add(input); result = CRUDStatusCode.SUCCESS; } else if (session != null && session.StatusId == CommonStatus.DELETE) { session.Name = input.Name; session.StatusId = CommonStatus.ACTIVE; _SessionRepository.Update(session); result = CRUDStatusCode.SUCCESS; } else { result = CRUDStatusCode.EXISTED; } } return(result); }
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 void Should_Throw_Exception_When_Course_IsArchived() { 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", IsArchived = true }; var AddedCourse = courseRepository.Add(SQLCourse); context.SaveChanges(); var SQLSession = new SessionTO() { //Id = 1, Attendees = new List <UserTO>() { AddedAttendee }, Course = AddedCourse, Teacher = AddedTeacher, }; Assert.ThrowsException <ArgumentException>(() => sessionRepository.Add(SQLSession)); } }
public ActionResult AddSession([Bind(Prefix = "Session")] Session item) { if (!ModelState.IsValid) { return(View("AddSession")); } ViewBag.error = "Seans saati veya tarih eklenmedi lütfen tekrar deneyiniz"; _sRep.Add(item); return(RedirectToAction("SeansList")); }
public void Add_CheckNumberofSession() { SessionRepository sessionRepository = new SessionRepository(); Session s1 = new Session { Pomodoro = new Pomodoro() }; sessionRepository.Add(s1); Assert.AreEqual(1, sessionRepository.Count); }
public void Sessions_Repository_Should_Add_Sucessfully() { //Action var session = _repository.Add(_session); //Assert session.Should().NotBeNull(); session.Id.Should().NotBe(0); var expectedSession = _context.Sessions.Find(session.Id); expectedSession.Should().NotBeNull(); expectedSession.Movie.Name.Should().Be(session.Movie.Name); }
private void GenerateSessions(DateTime startDate, DateTime endDate, int maxSessions) { var date = startDate; ISessionRepository repository = new SessionRepository(); while (date <= endDate) { for (int i = 0; i < maxSessions; i++) { var session = this.GenerateSession(date); repository.Add(session); } date = date.AddDays(1); } }
private void GenerateSessions(DateTime startDate, DateTime endDate, int maxSessions) { var date = startDate; ISessionRepository repository = new SessionRepository(); while (date <= endDate) { for (int i = 0; i < maxSessions; i++) { var session = this.GenerateSession(date); repository.Add(session); } date = date.AddDays(1); } }
protected Session CreateSession(long accountId, string username) { var newSession = new Session() { accountId = accountId, username = username, // sagolboss : 일회적으로 사용되는 값이므로 System.Guid를 사용하지 않고 간단한 Guid를 사용한다. authToken = Authentication.GenerateSecureNumber2(1, 9, 8), }; SessionRepository sessionRepository = new SessionRepository(); sessionRepository.Add(newSession.username, newSession); return(newSession); }
public void Should_Return_2_Session() { 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 Isabelle = new UserTO() { Name = "Isabelle Balkany", Email = "*****@*****.**", Role = UserRole.Attendee }; var AddedTeacher = userRepository.Add(Teacher); var AddedAttendee = userRepository.Add(Michou); var AddedAttendee2 = userRepository.Add(Isabelle); context.SaveChanges(); var SQLCourse = new CourseTO() { Name = "SQL" }; var MVCCourse = new CourseTO() { Name = "MVC" }; var AddedCourse = courseRepository.Add(SQLCourse); var AddedCourse2 = courseRepository.Add(MVCCourse); context.SaveChanges(); var SQLSession = new SessionTO() { Attendees = new List <UserTO>() { AddedAttendee }, Course = AddedCourse, Teacher = AddedTeacher, SessionDays = new List <SessionDayTO>() { new SessionDayTO() { Date = new DateTime(2020, 02, 20), PresenceType = SessionPresenceType.MorningAfternoon }, new SessionDayTO() { Date = new DateTime(2020, 02, 21), PresenceType = SessionPresenceType.MorningAfternoon } } }; var MVCSession = new SessionTO() { Attendees = new List <UserTO>() { AddedAttendee2 }, Course = AddedCourse, Teacher = AddedTeacher, SessionDays = new List <SessionDayTO>() { new SessionDayTO() { Date = new DateTime(2020, 03, 20), PresenceType = SessionPresenceType.MorningAfternoon }, new SessionDayTO() { Date = new DateTime(2020, 03, 21), PresenceType = SessionPresenceType.MorningAfternoon } } }; var AddedSession = sessionRepository.Add(SQLSession); context.SaveChanges(); Assert.AreEqual(0, sessionRepository.GetSessionsByDate(new DateTime(2020, 02, 20)).Count()); } }
public void ShouldReturn_2Students() { 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 Isabelle = new UserTO() { //Id = 45, Name = "Isabelle Balkany", Email = "*****@*****.**", Role = UserRole.Attendee }; var AddedTeacher = userRepository.Add(Teacher); var AddedAttendee = userRepository.Add(Michou); var AddedAttendee2 = userRepository.Add(Isabelle); 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, Isabelle }, Course = AddedCourse, Teacher = Teacher, }; var AddedSession = sessionRepository.Add(SQLSession); context.SaveChanges(); Assert.AreEqual(2, sessionRepository.GetStudents(AddedSession).Count()); } }
public void Modifying_Course() { 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() { Name = "Christian", Email = "*****@*****.**", Role = UserRole.Teacher }; var Michou = new UserTO() { Name = "Michou Miraisin", Email = "*****@*****.**", Role = UserRole.Attendee }; var Isabelle = new UserTO() { Name = "Isabelle Balkany", Email = "*****@*****.**", Role = UserRole.Attendee }; var AddedTeacher = userRepository.Add(Teacher); var AddedAttendee = userRepository.Add(Michou); context.SaveChanges(); var SQLCourse = new CourseTO() { Name = "SQL" }; var MVCCourse = new CourseTO() { Name = "MVC" }; var AddedCourse = courseRepository.Add(SQLCourse); var AddedCourse2 = courseRepository.Add(MVCCourse); context.SaveChanges(); var SQLSession = new SessionTO() { Attendees = new List <UserTO>() { AddedAttendee, }, Course = AddedCourse, Teacher = AddedTeacher, }; var AddedSession = sessionRepository.Add(SQLSession); context.SaveChanges(); Assert.AreEqual("SQL", AddedSession.Course.Name); AddedSession.Course = AddedCourse2; AddedSession = sessionRepository.Update(AddedSession); context.SaveChanges(); Assert.AreEqual("MVC", AddedSession.Course.Name); } }
public void IsInSession_WhenValid() { //arrange var options = new DbContextOptionsBuilder <RegistrationContext>() .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name) .Options; using var RSCxt = new RegistrationContext(options); IRSUserRepository userRepository = new UserRepository(RSCxt); IRSCourseRepository courseRepository = new CourseRepository(RSCxt); IRSSessionRepository sessionRepository = new SessionRepository(RSCxt); var Teacher = new UserTO() { Name = "Max", Email = "*****@*****.**", Role = UserRole.Teacher }; var Jack = new UserTO() { Name = "Jack Jack", Email = "*****@*****.**", Role = UserRole.Attendee }; var John = new UserTO() { Name = "John", Email = "*****@*****.**", Role = UserRole.Attendee }; var AddedUser0 = userRepository.Add(Teacher); var AddedUser1 = userRepository.Add(Jack); var AddedUser2 = userRepository.Add(John); RSCxt.SaveChanges(); var SQLCourse = new CourseTO() { Name = "SQL" }; var AddedCourse = courseRepository.Add(SQLCourse); RSCxt.SaveChanges(); var SQLSession = new SessionTO() { Attendees = new List <UserTO>() { AddedUser1 }, Course = AddedCourse, Teacher = AddedUser0, }; var AddedSession = sessionRepository.Add(SQLSession); RSCxt.SaveChanges(); //act //assert Assert.AreEqual(3, userRepository.GetAll().Count()); Assert.AreEqual(2, userRepository.GetUsersBySession(AddedSession).Count()); }
public Status Post() { SessionRepository.Add(Input); return(Status.Created); }
public OperationResult Post(Session item) { SessionRepository.Add(item); return(new OperationResult.Created()); }
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>() { Michou }, Course = AddedCourse, Teacher = Teacher, }; //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(1, sessionRepository.GetAll().Count()); } }
// POST api/session public void Post([FromBody]Session value) { SessionRepository.Add(value); }