public void ResumeSession_Succcess() { //Arrange int pid = gbl_pid++; var connection = CreateConnection(); CreateTestPerson(pid); //Act Session_Reply session_reply = connection.StartSession(new PersonProject_Request { PersonId = pid, ProjectId = 23 }); connection.PauseSession(new SessionId_Request { Id = session_reply.Session.Id }); Empty empty = connection.ResumeSession(new SessionId_Request { Id = session_reply.Session.Id }); //Assert Assert.IsNotNull(empty); //Clean-up DeleteTestPerson(pid); }
public override Task <Session_Reply> ConvertLastHeartbeatToEnd(SessionId_Request request, ServerCallContext context) { Session_Reply session_Reply = new Session_Reply(); Session session = new Session(); MySqlConnection connection = CreateDBConnection(); MySqlCommand cmd; string lhb; Set_lhb_ToLastHeartbeat(request, connection, out cmd, out lhb); cmd.CommandText = $"UPDATE trackerdb.session SET `end` = '{lhb}' WHERE `sessionId` = {request.Id};"; cmd.ExecuteNonQuery(); cmd.CommandText = $"SELECT `sessionId`, `personId`, `projectId`, `start`, `end`, `lastHeartbeat` FROM trackerdb.session WHERE `sessionId` = {request.Id};"; var reader = cmd.ExecuteReader(); reader.Read(); session.Id = Convert.ToInt32(reader["sessionId"]); session.PersonId = Convert.ToInt32(reader["personId"]); session.ProjectId = Convert.ToInt32(reader["projectId"]); session.Start = Convert.ToString(reader["start"]); if (reader["lastHeartbeat"] != null) { session.LastHeartbeat = Convert.ToString(reader["lastHeartbeat"]); } if (reader["end"] != null) { session.End = Convert.ToString(reader["end"]); } session_Reply.Session = session; cmd.Dispose(); connection.Close(); connection.Dispose(); return(Task.FromResult(session_Reply)); }
public void PuaseSession_Succcess() { //Arrange //setup the testing objects and prepare the prerequisites for your test. int pid = gbl_pid++; var connection = CreateConnection(); CreateTestPerson(pid); //Act //Make test session. Session_Reply session_reply = connection.StartSession(new PersonProject_Request { PersonId = pid, ProjectId = 23 }); SessionPauseId_Reply sessionPauseId = connection.PauseSession(new SessionId_Request { Id = session_reply.Session.Id }); //Assert //verify the result. Assert.IsNotNull(sessionPauseId); //Clean-up DeleteTestPerson(pid); }
public void StartSession_Succcess() { //Arrange //setup the testing objects and prepare the prerequisites for your test. int pid = gbl_pid++; var connection = CreateConnection(); CreateTestPerson(pid); //Act //perform the actual work of the test. Session_Reply session_reply = connection.StartSession(new PersonProject_Request { PersonId = pid, ProjectId = 23 }); Session session = session_reply.Session; //Assert //verify the result. Assert.AreEqual(pid, session.PersonId); Assert.AreEqual(23, session.ProjectId); //Clean-up DeleteSession(session.Id); DeleteTestPerson(pid); }
public void ConvertLastHeartbeatToEnd() { //Arrange var connection = CreateConnection(); //Act Session_Reply session_Reply = connection.ConvertLastHeartbeatToEnd(new SessionId_Request { Id = 1439 /*SESSION ID HERE*/ }); //Assert Assert.IsNotNull(session_Reply.Session.End); }
public override Task <Empty> ResumeSession(SessionId_Request request, ServerCallContext context) { Session_Reply session_Reply = new Session_Reply(); SessionPauseId_Reply sessionPauseId = new SessionPauseId_Reply(); MySqlConnection connection = CreateDBConnection(); var cmd = connection.CreateCommand(); cmd.CommandText = $"UPDATE trackerdb.session_pause SET `resume` = NOW() WHERE `sessionId` = { request.Id};"; cmd.ExecuteNonQuery(); cmd.Dispose(); connection.Close(); connection.Dispose(); return(Task.FromResult(new Empty())); }
public void StopSession_Succcess() { //Arrange //setup the testing objects and prepare the prerequisites for your test. var connection = CreateConnection(); //Act Session_Reply session_reply = connection.StopSession(new SessionId_Request { Id = 1431 }); //Assert Assert.IsNotNull(session_reply.Session.End); }
public override Task <SessionPauseId_Reply> PauseSession(SessionId_Request request, ServerCallContext context) { Session_Reply session_Reply = new Session_Reply(); SessionPauseId_Reply sessionPauseId = new SessionPauseId_Reply(); MySqlConnection connection = CreateDBConnection(); var cmd = connection.CreateCommand(); cmd.CommandText = $"INSERT INTO trackerdb.session_pause (sessionId, pause) VALUES({request.Id},NOW());"; cmd.ExecuteNonQuery(); cmd.CommandText = "SELECT LAST_INSERT_ID();"; var reader = cmd.ExecuteReader(); reader.Read(); sessionPauseId.Id = Convert.ToInt32(reader["LAST_INSERT_ID()"]); cmd.Dispose(); connection.Close(); connection.Dispose(); return(Task.FromResult(sessionPauseId)); }
public override Task <Session_Reply> StartSession(PersonProject_Request request, ServerCallContext context) { Session_Reply session_Reply = new Session_Reply(); Session session = new Session(); MySqlConnection connection = CreateDBConnection(); var cmd = connection.CreateCommand(); cmd.CommandText = $"INSERT INTO trackerdb.session (`personId`, `projectId`, `start`, `end`, `lastHeartbeat`) VALUES ({request.PersonId}, {request.ProjectId}, NOW(), NULL, NULL );"; cmd.ExecuteNonQuery(); cmd.CommandText = $"SELECT `sessionId`, `personId`, `projectId`, `start` FROM trackerdb.session WHERE `sessionId` = (SELECT MAX(`sessionId`) FROM trackerdb.session) AND `personId` = {request.PersonId} AND `projectId` = {request.ProjectId};"; var reader = cmd.ExecuteReader(); reader.Read(); session.Id = Convert.ToInt32(reader["sessionId"]); session.PersonId = Convert.ToInt32(reader["personId"]); session.ProjectId = Convert.ToInt32(reader["projectId"]); session.Start = Convert.ToString(reader["start"]); session_Reply.Session = session; cmd.Dispose(); connection.Close(); connection.Dispose(); return(Task.FromResult(session_Reply)); }