public void Intg_DeleteSession_Success() { SetupOneUserOneProjectDb(); using (ShimsContext.Create()) { var hub = CreateAuthenticatedHub(); hub.DeleteSession(1); var dbcontext = new CoStartDbContext(); var modifiedSession = dbcontext.WorkSessions.Find(1); Assert.IsTrue(modifiedSession.IsDeleted); } }
public void Init() { Database.SetInitializer(new DropCreateDatabaseAlways<CoStartDbContext>()); var _db = new CoStartDbContext(); _db.Database.Initialize(force: true); var _dbResults = new CoStartDbContext(); // This forces the database to initialise at this point with the initialization data / Empty DB var count = _db.Users.Count(); var resultCount = _dbResults.Users.Count(); if (count != resultCount) throw new InvalidOperationException("We do not have a consistant DB experiance."); }
public void Intg_AddSessionForProjectUserByCoStarter_SessionAfterLatestTime_Success() { SetupOneUserOneProjectDb(); var hub = new CoStartHub(); var endTime = new DateTime(2012, 2, 2, 1, 15, 0); var session = new WorkSession { StartTime = new DateTime(2012, 2, 2, 1, 0, 0), EndTime = endTime, }; hub.AddSessionForProjectUserByCoStarter(1, "*****@*****.**", session); var dbcontext = new CoStartDbContext(); var sessionCreated = dbcontext.WorkSessions.Single(x => x.EndTime == new DateTime(2012, 2, 2, 1, 15, 0)); Assert.AreEqual(1, sessionCreated.ProjectId); Assert.AreEqual(1, sessionCreated.UserId); var projectEnroll = dbcontext.ProjectUserEnrollments.Where(x => x.ProjectId == 1 && x.UserId == 1).Single(); Assert.AreEqual(endTime, projectEnroll.LatestReportTime); }
public void Intg_UpdateSession_Add1MoreHour_Success() { SetupOneUserOneProjectDb(); using (ShimsContext.Create()) { var hub = CreateAuthenticatedHub(); var session = hub.GetWorkSessionsForProject(1, 0, 1).Single(); var oriEndTime = session.EndTime; var newEndTime = session.EndTime.AddHours(1); hub.UpdateSession(session); var dbcontext = new CoStartDbContext(); var modifiedSession = dbcontext.WorkSessions.Find(session.Id); Assert.AreEqual(oriEndTime.AddHours(1), modifiedSession.EndTime.AddHours(1)); } }
private static void SetupOneUserOneProjectDb() { var dbcontext = new CoStartDbContext(); dbcontext.Projects.Add(new Project { Id = 1, Name = "Test1's project1", Url = "http://*****:*****@hgggmail.com", }); dbcontext.Roles.Add(new Role { Id = 1, Name = "Collaborator" }); dbcontext.ProjectUserEnrollments.Add(new ProjectUserEnrollment { Id = 1, ProjectId = 1, UserId = 1, LatestReportTime = new DateTime(2012, 2, 2, 1, 0, 0), RoleId = 1, }); var session = new WorkSession { StartTime = new DateTime(2012, 2, 2, 0, 0, 0), EndTime = new DateTime(2012, 2, 2, 1, 0, 0), UserId = 1, ProjectId = 1, }; dbcontext.WorkSessions.Add(session); dbcontext.SaveChanges(); }