public void ConstructorShouldReturnSameTextForQuestionWhenGivenValidParameters() { var nameQuestion = "Bonus"; var bonusQuestion = new BonusQuestion(nameQuestion, DifficultyLevel.Hard, CategoryType.Geography, 5); Assert.AreEqual("Bonus", bonusQuestion.QuestionText); }
private void BonusQuestionLogic() { BonusQuestion b = new BonusQuestion(); string quest = b.GenerateQuestion(); correctBAns = b.GenerateAnswer(); string wrongAnsA = b.GenerateUniqueWrongAnswer(); string wrongAnsB = b.GenerateUniqueWrongAnswer(); string wrongAnsC = b.GenerateUniqueWrongAnswer(); List <string> listOfAns = new List <string>() { correctBAns, wrongAnsA, wrongAnsB, wrongAnsC }; List <int> listOfInts = new List <int>(); for (int i = 0; i < 4; i++) { listOfInts.Add(i); } listOfInts.Sort((a, c) => 1 - 2 * Random.Range(0, 1)); int shuffledIntA = listOfInts[0]; int shuffledIntB = listOfInts[1]; int shuffledIntC = listOfInts[2]; int shuffledIntD = listOfInts[3]; B = new BonusQuestion(quest, listOfAns[shuffledIntA], listOfAns[shuffledIntB], listOfAns[shuffledIntC], listOfAns[shuffledIntD]); }
public void ConstructorShouldReturnProperlyCalculatedPointsBasedOnFormula() { var pointsMultiplier = 5; var bonusQuestion = new BonusQuestion("Bonus", DifficultyLevel.Normal, CategoryType.Geography, pointsMultiplier); var pointsAccordingToFormula = (int)DifficultyLevel.Normal * 100 * pointsMultiplier; Assert.AreEqual(pointsAccordingToFormula, bonusQuestion.Points); }
private void btnSave_Click(object sender, RoutedEventArgs e) { if (mIsNormalQuestion) { Round round = new Round(); round.Question = new Question(tbQuestion.Text); round.Answers = new ObservableCollection <Answer>(); if (CheckNonEmptyStackPanelTextBoxes(spAnswer1)) { round.Answers.Add(new Answer(tbAnswer1.Text, uint.Parse(tbAnswer1Points.Text))); } if (CheckNonEmptyStackPanelTextBoxes(spAnswer2)) { round.Answers.Add(new Answer(tbAnswer2.Text, uint.Parse(tbAnswer2Points.Text))); } if (CheckNonEmptyStackPanelTextBoxes(spAnswer3)) { round.Answers.Add(new Answer(tbAnswer3.Text, uint.Parse(tbAnswer3Points.Text))); } if (CheckNonEmptyStackPanelTextBoxes(spAnswer4)) { round.Answers.Add(new Answer(tbAnswer4.Text, uint.Parse(tbAnswer4Points.Text))); } if (CheckNonEmptyStackPanelTextBoxes(spAnswer5)) { round.Answers.Add(new Answer(tbAnswer5.Text, uint.Parse(tbAnswer5Points.Text))); } if (CheckNonEmptyStackPanelTextBoxes(spAnswer6)) { round.Answers.Add(new Answer(tbAnswer6.Text, uint.Parse(tbAnswer6Points.Text))); } if (CheckNonEmptyStackPanelTextBoxes(spAnswer7)) { round.Answers.Add(new Answer(tbAnswer7.Text, uint.Parse(tbAnswer7Points.Text))); } if (CheckNonEmptyStackPanelTextBoxes(spAnswer8)) { round.Answers.Add(new Answer(tbAnswer8.Text, uint.Parse(tbAnswer8Points.Text))); } round.Answers = new ObservableCollection <Answer>(round.Answers.OrderByDescending(a => a.PointValue)); QuestionComplete?.Invoke(this, new EventArgs <Round>(round)); } else { BonusQuestion bonusQuestion = new BonusQuestion() { Question = new Question(tbQuestion.Text), Answer = new Answer(tbAnswer1.Text, uint.Parse(tbAnswer1Points.Text)) }; BonusQuestionComplete?.Invoke(this, new EventArgs <BonusQuestion>(bonusQuestion)); } this.Close(); }
public QuestionBuilder(BonusQuestion bonusQuestion) { mIsNormalQuestion = false; mCanSave = true; mBonusQuestion = bonusQuestion.Copy(); PropertyChanged += PropertyChanged_RenameAnswerField; Loaded += OnLoaded_UpdateIsNormalQuestion; Loaded += OnLoaded_InitializeBonus; DataContext = this; InitializeComponent(); }
public HttpResponseMessage PostChallengeQuestion(BonusQuestion obj) { if (obj == null) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } try { db.BonusQuestions.Add(obj); db.SaveChanges(); var result = obj; return(Request.CreateResponse(HttpStatusCode.OK, result)); } catch (Exception) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Falha ao incluir Pergunta-Bonus.")); } }
private void DisplayQuestionType() { switch (engine.QuizzardQuestions[countQuestions].QuestionType) { case QuestionType.Normal: BonusType.Visibility = Visibility.Hidden; BonusPoints.Visibility = Visibility.Hidden; TimeType.Visibility = Visibility.Hidden; SecondsTimer.Visibility = Visibility.Hidden; break; case QuestionType.Timed: TimeType.Visibility = Visibility.Visible; SecondsTimer.Visibility = Visibility.Visible; TimedQuestion timeQuestion = engine.QuizzardQuestions[countQuestions] as TimedQuestion; this.timer = timeQuestion.Time; SecondsTimer.Text = this.timer.ToString(); this.dispatcherTimer = new DispatcherTimer(); this.dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick); this.dispatcherTimer.Interval = new TimeSpan(0, 0, 1); this.dispatcherTimer.Start(); BonusType.Visibility = Visibility.Hidden; BonusPoints.Visibility = Visibility.Hidden; break; case QuestionType.Bonus: BonusType.Visibility = Visibility.Visible; BonusQuestion bonusQuestion = engine.QuizzardQuestions[countQuestions] as BonusQuestion; BonusPoints.Text = $"x{bonusQuestion.PointsMultiplier}"; BonusPoints.Visibility = Visibility.Visible; TimeType.Visibility = Visibility.Hidden; SecondsTimer.Visibility = Visibility.Hidden; break; default: break; } }