public void GetInterviewQuestions_EmptyObjectId_Failure() { List <InterviewQuestion> oQuestions; var res = InterviewQuestion.GetInterviewQuestions(_mockServer, "", out oQuestions); Assert.IsFalse(res.Success, "Calling GetInterviewQuestion with did not fail"); }
public void GetInterviewHandlerQuestionRecording_NullConnectionServer_Failure() { //GetInterviewHandlerQuestionRecording var res = InterviewQuestion.GetInterviewHandlerQuestionRecording(null, "c:\\test.wav", "objectid", 1); Assert.IsFalse(res.Success, "Calling GetInterviewHandlerQuestionRecording with null ConnectionServer did not fail"); }
public void SetQuestionRecording_Success() { InterviewQuestion oQuestion = GetInterviewQuestionFromTemporaryHandler(); //set stream var res = oQuestion.SetQuestionRecording("Dummy.wav", true); Assert.IsTrue(res.Success, "Setting recording to wav file failed:" + res); //fetch it again, make sure it downloads res = oQuestion.RefetchInterviewHandlerData(); Assert.IsTrue(res.Success, "failed to refetch interview handler data"); string strTemp = Path.GetTempFileName() + ".wav"; res = oQuestion.GetQuestionRecording(strTemp); Assert.IsTrue(res.Success, "Fetching recording that was just uploaded failed:" + res); Assert.IsTrue(File.Exists(strTemp), "Wav file target does not exist after download:" + strTemp); try { File.Delete(strTemp); } catch (Exception ex) { Assert.Fail("Failure deleting temporary file for question recording fetch:" + ex); } }
public void GetInterviewQuestions_NullConnectionServer_Failure() { List <InterviewQuestion> oQuestions; var res = InterviewQuestion.GetInterviewQuestions(null, "objectid", out oQuestions); Assert.IsFalse(res.Success, "Calling GetInterviewQuestion with did not fail"); }
public void GetInterviewQuestion_NullConnectionServer_Failure() { InterviewQuestion oQuestion; var res = InterviewQuestion.GetInterviewQuestion(out oQuestion, null, "objectid", 1); Assert.IsFalse(res.Success, "Calling GetInterviewQuestion with did not fail"); }
public async Task <ActionResult> Create(InterviewQuestion interviewQuestion) { try { var user = await GetCurrentUserAsync(); var question = new InterviewQuestion { Question = interviewQuestion.Question, Answer = interviewQuestion.Answer, ApplicationUserId = user.Id }; _context.InterviewQuestions.Add(question); //Save changes to the databse await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public void GetInterviewQuestion_EmptyObjectId_Failure() { InterviewQuestion oQuestion; var res = InterviewQuestion.GetInterviewQuestion(out oQuestion, _mockServer, "", 1); Assert.IsFalse(res.Success, "Calling GetInterviewQuestion with did not fail"); }
public void InterviewQuestion_Update_Success() { InterviewQuestion oQuestion = GetInterviewQuestionFromTemporaryHandler(); //change description text var res = oQuestion.Update(true, 11, "testing"); Assert.IsTrue(res.Success, "Failed to update question values:" + res); }
public void InterviewQuestion_Update_Failure() { InterviewQuestion oQuestion = GetInterviewQuestionFromTemporaryHandler(); //set invalid property var res = oQuestion.Update(true, 2222, "testing"); Assert.IsFalse(res.Success, "Trying to set invalid question response length did not fail."); }
public void GetQuestionRecording_Failure() { InterviewQuestion oQuestion = GetInterviewQuestionFromTemporaryHandler(); //try and fetch stream string strTemp = Path.GetTempFileName() + ".wav"; var res = oQuestion.GetQuestionRecording(strTemp); Assert.IsFalse(res.Success, "Fetching recording that does not exist did not fail"); }
public List <InterviewQuestion> InterviewQuestionsById(string id) { try { var objInterviewQuestions = new List <InterviewQuestion>(); using (SqlConnection connection = new SqlConnection()) { connection.ConnectionString = ConfigurationManager.AppSettings["sqlConnection"]; SqlCommand sqlCommand = new SqlCommand { Connection = connection, CommandType = CommandType.StoredProcedure, CommandText = "[DBO].[Get_InterviewQuestionsById]" }; connection.Open(); _adp = new SqlDataAdapter(sqlCommand); _dt = new DataTable(); _adp.Fill(_dt); } if (_dt.Rows.Count > 0) { foreach (DataRow item in _dt.Rows) { InterviewQuestion objInterviewQuestion = new InterviewQuestion(); if (!string.IsNullOrEmpty(Convert.ToString(item["CategoryId"]))) { objInterviewQuestion.CategoryId = Convert.ToInt32(item["CategoryId"]); } if (!string.IsNullOrEmpty(Convert.ToString(item["Heading"]))) { objInterviewQuestion.Heading = Convert.ToString(item["Heading"]); } if (!string.IsNullOrEmpty(Convert.ToString(item["Question"]))) { objInterviewQuestion.Question = Convert.ToString(item["Question"]); } if (!string.IsNullOrEmpty(Convert.ToString(item["Answer"]))) { objInterviewQuestion.Answer = Convert.ToString(item["Answer"]); } if (!string.IsNullOrEmpty(Convert.ToString(item["Score"]))) { objInterviewQuestion.Score = Convert.ToInt32(item["Score"]); } objInterviewQuestions.Add(objInterviewQuestion); } } return(objInterviewQuestions); } catch (Exception) { throw; } }
public IActionResult QuestionCreate(InterviewQuestion postt) { if (!ModelState.IsValid) { return(View()); } _db.QuestionAnswerr.Add(postt); _db.SaveChanges(); return(View()); }
public InterviewQuestion GetQuestionById(int questionId) { try { InterviewQuestion objInterviewQuestion = new InterviewQuestion(); return(objInterviewQuestion); } catch (Exception) { throw; } }
public IHttpActionResult CreateQuestion(InterviewQuestion question) { if (!ModelState.IsValid) { throw new HttpResponseException(HttpStatusCode.BadRequest); } _context.Questions.Add(question); _context.SaveChanges(); return(Created(new Uri(Request.RequestUri + "/" + question.Id), question)); }
public void GetInterviewQuestions_Fetch_Success() { var oQuestions = _tempHandler.GetInterviewQuestions(); Assert.IsNotNull(oQuestions, "Null returned for questions fetch"); Assert.IsTrue(oQuestions.Count > 1, "No questions returned from fetch"); //exercise tostring and dumpallprops interfaces InterviewQuestion oQuestion = oQuestions[0]; Console.WriteLine(oQuestions.ToString()); Console.WriteLine(oQuestion.DumpAllProps()); }
public async Task <ActionResult> Delete(int id, InterviewQuestion interviewQuestion) { try { _context.InterviewQuestions.Remove(interviewQuestion); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public void Interviewer_Test() { _errorString = ""; List <InterviewHandler> oInterviewHandlers; var res = InterviewHandler.GetInterviewHandlers(_connectionServer, out oInterviewHandlers, 1, 2); Assert.IsTrue(res.Success & oInterviewHandlers.Count > 0, "Failed to fetch interview handlers:" + res); Assert.IsTrue(string.IsNullOrEmpty(_errorString), "Error parsing Json for interview handlers:" + _errorString); List <InterviewQuestion> oQuestions; res = InterviewQuestion.GetInterviewQuestions(_connectionServer, oInterviewHandlers[0].ObjectId, out oQuestions); Assert.IsFalse(res.Success == false || oQuestions.Count == 0, "Failed to fetch interviewer questions"); Assert.IsTrue(string.IsNullOrEmpty(_errorString), "Error parsing Json for interview handler questions:" + _errorString); }
public void UpdateQuestion(int id, InterviewQuestion question) { if (!ModelState.IsValid) { throw new HttpResponseException(HttpStatusCode.BadRequest); } var questionInDb = _context.Questions.SingleOrDefault(q => q.Id == id); if (questionInDb == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } questionInDb.Question = question.Question; questionInDb.QuestionCategoryId = question.QuestionCategoryId; _context.SaveChanges(); }
public void InterviewQuestion_FetchTest() { List <InterviewQuestion> oQuestions; var res = InterviewQuestion.GetInterviewQuestions(_connectionServer, _tempHandler.ObjectId, out oQuestions); Assert.IsTrue(res.Success, "Failed to fetch interview questions:" + res); Assert.IsTrue(oQuestions.Count > 0, "No questions returned from fetch"); InterviewQuestion oQuestion; res = InterviewQuestion.GetInterviewQuestion(out oQuestion, _connectionServer, _tempHandler.ObjectId, 1); Assert.IsTrue(res.Success, "Failed to fetch question #1:" + res); Console.WriteLine(oQuestion.ToString()); oQuestion.DumpAllProps(); res = oQuestion.Update(false, 11, "testing"); Assert.IsTrue(res.Success, "Updating question failed:" + res); res = InterviewQuestion.GetInterviewQuestion(out oQuestion, _connectionServer, _tempHandler.ObjectId, 999); Assert.IsFalse(res.Success, "Fetching invalid question number did not fail"); }
public void InterviewQuestion_RecordedStreamTests() { List <InterviewQuestion> oQuestions = _tempHandler.GetInterviewQuestions(true); Assert.IsNotNull(oQuestions, "Null questions list created"); Assert.IsTrue(oQuestions.Count > 0, "No questions returned from fetch"); //fetch just a single question instead of all of them InterviewQuestion oQuestion; WebCallResult res = InterviewQuestion.GetInterviewQuestion(out oQuestion, _connectionServer, _tempHandler.ObjectId, 19); Assert.IsTrue(res.Success, "Failed to fetch single interview question:" + res); string strFileName = Path.GetTempFileName().Replace(".tmp", ".wav"); res = oQuestion.GetQuestionRecording(strFileName); Assert.IsFalse(res.Success, "Fetching recording that does not exist should return an error"); res = oQuestion.SetQuestionRecording("Dummy.wav", true); Assert.IsTrue(res.Success, "Uplading greeting recording failed:" + res); res = oQuestion.RefetchInterviewHandlerData(); Assert.IsTrue(res.Success, "Refetching data for question failed:" + res); res = oQuestion.GetQuestionRecording(strFileName); Assert.IsTrue(res.Success, "Fetching recording that was just uploaded failed:" + res); Assert.IsTrue(File.Exists(strFileName), "Wav file for download did not get created on hard drive:" + strFileName); try { File.Delete(strFileName); } catch (Exception ex) { Assert.Fail("Failed to delete temporary wav download file:" + ex); } }
public ActionResult Save(InterviewQuestion question) { if (!ModelState.IsValid) { var viewModel = new CategoriesForSingleQuestionViewModel { Categories = _context.Categories.ToList(), Question = question }; return View("QuestionForm", viewModel); } if (question.Id == 0) _context.Questions.Add(question); else { var questionInDb = _context.Questions.Single(q => q.Id == question.Id); questionInDb.Question = question.Question; questionInDb.QuestionCategoryId = question.QuestionCategoryId; } _context.SaveChanges(); return RedirectToAction("Index", "Question"); }
public void UpdateInterviewHandlerQuestion_NullConnectionServer_Failure() { var res = InterviewQuestion.UpdateInterviewHandlerQuestion(null, "objectid", 1, true, 1, "test"); Assert.IsFalse(res.Success, "Calling UpdateInterviewHandlerQuestion with did not fail"); }
public StartInterviewResponse StartInterview(StartInterviewRequest request) { StartInterviewResponse response = new StartInterviewResponse(); try { Common.Helpers.ValidationHelper.ValidateRequiredField(request.Token, "Token"); InterviewToken token = InterviewToken.FromBytes(EncryptionHelper.DecryptURL(Convert.FromBase64String(request.Token))); DbContext context = DataController.CreateDbContext(); E::Interview interview = context.Interviews .Where(i => i.ID == token.InterviewID) .FirstOrDefault(); Common.Helpers.ValidationHelper.Assert(interview != null, "Invalid token"); InterviewStatus status = StatusHelper.GetInterviewStatus(interview); Common.Helpers.ValidationHelper.Assert(status == InterviewStatus.WaitingForApplicant || status == InterviewStatus.InProgress, "Invalid state"); int secondsRemaining = TimeHelper.CalculateSecondsRemaining(interview); Common.Helpers.ValidationHelper.Assert(secondsRemaining > -10, "Interview has already been completed."); response.SecondsRemaining = Math.Max(0, secondsRemaining); var questions = context.InterviewQuestions .Where(i => i.InterviewID == token.InterviewID) .Select(i => new { ID = i.ID, Name = i.Question.Name, QuestionBody = i.Question.QuestionBody, QuestionTypeID = i.Question.QuestionTypeID }) .ToList(); var attempts = context.Attempts .Where(a => a.InterviewQuestion.InterviewID == token.InterviewID) .Select(a => new { InterviewQuestionID = a.InterviewQuestionID }) .ToList(); IList<InterviewQuestion> interviewQuestions = new List<InterviewQuestion>(); foreach (var question in questions) { string questionBody = DataController.DownloadBlob(question.QuestionBody.ToString()); InterviewQuestion newInterviewQuestion = new InterviewQuestion(); newInterviewQuestion.ID = question.ID; newInterviewQuestion.Name = question.Name; newInterviewQuestion.QuestionBody = questionBody; newInterviewQuestion.Submitted = attempts.Any(a => a.InterviewQuestionID == question.ID); interviewQuestions.Add(newInterviewQuestion); } response.Questions = interviewQuestions.ToArray(); if (status == InterviewStatus.WaitingForApplicant) { interview.StartedDate = DateTime.UtcNow; context.SaveChanges(); try { SendInterviewCompletedEmail(token, context, interview); } catch (Exception ex) { ExceptionHelper.Log(ex, interview.CreatedBy); } } } catch (Common.Exceptions.ValidationException ex) { throw new WebFaultException<string>(ex.Message, System.Net.HttpStatusCode.BadRequest); } catch (Exception ex) { ExceptionHelper.Log(ex, null); throw new WebFaultException<string>("An unknown error has occurred.", System.Net.HttpStatusCode.InternalServerError); } return response; }
public void Question_Constructor_InvalidObjectId_Failure() { var oTest = new InterviewQuestion(_connectionServer, "bogus", 1); Console.WriteLine(oTest); }
public void InterviewQuestion_StaticFailureTest() { //GetInterviewHandlerQuestionRecording var res = InterviewQuestion.GetInterviewHandlerQuestionRecording(null, "c:\\test.wav", "objectid", 1); Assert.IsFalse(res.Success, ""); res = InterviewQuestion.GetInterviewHandlerQuestionRecording(_connectionServer, "c:\\test.wav", "objectid", 1); Assert.IsFalse(res.Success, ""); res = InterviewQuestion.GetInterviewHandlerQuestionRecording(_connectionServer, "", "objectid", 1); Assert.IsFalse(res.Success, ""); res = InterviewQuestion.GetInterviewHandlerQuestionRecording(_connectionServer, "c:\\bogus\\bogus\\temp.wav", "objectid", 1); Assert.IsFalse(res.Success, ""); res = InterviewQuestion.GetInterviewHandlerQuestionRecording(_connectionServer, "c:\\test.wav", "", 1); Assert.IsFalse(res.Success, ""); res = InterviewQuestion.GetInterviewHandlerQuestionRecording(_connectionServer, "c:\\test.wav", _tempHandler.ObjectId, 999); Assert.IsFalse(res.Success, ""); //GetInterviewQuestion InterviewQuestion oQuestion; res = InterviewQuestion.GetInterviewQuestion(out oQuestion, null, "objectid", 1); Assert.IsFalse(res.Success, ""); res = InterviewQuestion.GetInterviewQuestion(out oQuestion, _connectionServer, "objectid", 1); Assert.IsFalse(res.Success, ""); res = InterviewQuestion.GetInterviewQuestion(out oQuestion, _connectionServer, "", 1); Assert.IsFalse(res.Success, ""); res = InterviewQuestion.GetInterviewQuestion(out oQuestion, _connectionServer, _tempHandler.ObjectId, 999); Assert.IsFalse(res.Success, ""); //GetInterviewQuestions List <InterviewQuestion> oQuestions; res = InterviewQuestion.GetInterviewQuestions(null, "objectid", out oQuestions); Assert.IsFalse(res.Success, ""); res = InterviewQuestion.GetInterviewQuestions(_connectionServer, "", out oQuestions); Assert.IsFalse(res.Success, ""); //SetInterviewHandlerQuestionRecording res = InterviewQuestion.SetInterviewHandlerQuestionRecording(null, "c:\\temp.wav", "objectid", 1, true); Assert.IsFalse(res.Success, ""); res = InterviewQuestion.SetInterviewHandlerQuestionRecording(_connectionServer, "bogus.wav", "objectid", 1, true); Assert.IsFalse(res.Success, ""); res = InterviewQuestion.SetInterviewHandlerQuestionRecording(_connectionServer, "bogus.wav", "", 1, true); Assert.IsFalse(res.Success, ""); res = InterviewQuestion.SetInterviewHandlerQuestionRecording(_connectionServer, "Dummy.wav", _tempHandler.ObjectId, 999, true); Assert.IsFalse(res.Success, ""); //SetInterviewHandlerQuestionRecordingToStreamFile res = InterviewQuestion.SetInterviewHandlerQuestionRecordingToStreamFile(null, "objectid", 1, "streamid"); Assert.IsFalse(res.Success, ""); res = InterviewQuestion.SetInterviewHandlerQuestionRecordingToStreamFile(_connectionServer, "objectid", 1, "streamid"); Assert.IsFalse(res.Success, ""); res = InterviewQuestion.SetInterviewHandlerQuestionRecordingToStreamFile(_connectionServer, "", 1, "streamid"); Assert.IsFalse(res.Success, ""); res = InterviewQuestion.SetInterviewHandlerQuestionRecordingToStreamFile(_connectionServer, _tempHandler.ObjectId, 1, ""); Assert.IsFalse(res.Success, ""); res = InterviewQuestion.SetInterviewHandlerQuestionRecordingToStreamFile(_connectionServer, _tempHandler.ObjectId, 999, "streamId"); Assert.IsFalse(res.Success, ""); //UpdateInterviewHandlerQuestion res = InterviewQuestion.UpdateInterviewHandlerQuestion(null, "objectid", 1, true, 1, "test"); Assert.IsFalse(res.Success, ""); res = InterviewQuestion.UpdateInterviewHandlerQuestion(_connectionServer, "objectid", 1, true, 1, "test"); Assert.IsFalse(res.Success, ""); res = InterviewQuestion.UpdateInterviewHandlerQuestion(_connectionServer, "", 1, true, 1, "test"); Assert.IsFalse(res.Success, ""); res = InterviewQuestion.UpdateInterviewHandlerQuestion(_connectionServer, _tempHandler.ObjectId, 999, true, 1, "test"); Assert.IsFalse(res.Success, ""); }
public void Question_Constructor_EmptyObjectId_Failure() { var oTest = new InterviewQuestion(_mockServer, "", 1); Console.WriteLine(oTest); }
public void UpdateInterviewHandlerQuestion_EmptyOBjectId_Failure() { var res = InterviewQuestion.UpdateInterviewHandlerQuestion(_mockServer, "", 1, true, 1, "test"); Assert.IsFalse(res.Success, "Calling UpdateInterviewHandlerQuestion with empty objectid did not fail"); }
public void Question_Consturctor_NullConnectionServer_Failure() { var oTest = new InterviewQuestion(null, "bogus", 1); Console.WriteLine(oTest); }
public void Question_Constructor_InvalidQuestionNumber_Failure() { var oTest = new InterviewQuestion(_connectionServer, _tempHandler.ObjectId, 999); Console.WriteLine(oTest); }
public void SetInterviewHandlerQuestionRecordingToStreamFile_EmptyStreamId_Failure() { var res = InterviewQuestion.SetInterviewHandlerQuestionRecordingToStreamFile(_mockServer, "ObjectId", 1, ""); Assert.IsFalse(res.Success, "Calling SetInterviewHandlerQuestionRecordingToStreamFile with empty streamId did not fail"); }
// GET: InterviewQuestions/Create public async Task <ActionResult> Create() { var interviewQuestion = new InterviewQuestion(); return(View(interviewQuestion)); }