public Highscore(string username, Guid dictionaryId, QuestionResult questionResult)
 {
     Username = username;
     QuestionResult = questionResult;
     QuestionResultId = questionResult.Id;
     DictionaryId = dictionaryId;
 }
        public void ShouldReturnCorrectScore(double seconds, int numberOfCorrectAnswers, int numberOfIncorrectAnswers, int expectedScore)
        {
            var questionResult = new QuestionResult();

            for (var i = 0; i < numberOfCorrectAnswers; i++)
            {
                questionResult.AddAnswer(new Answer(true,
                                                    DateTime.Now,
                                                    TimeSpan.FromSeconds(seconds/
                                                                         (numberOfCorrectAnswers +
                                                                          numberOfIncorrectAnswers)), null));
            }

            for (var i = 0; i < numberOfIncorrectAnswers; i++)
            {
                questionResult.AddAnswer(new Answer(false,
                                                    DateTime.Now,
                                                    TimeSpan.FromSeconds(seconds/
                                                                         (numberOfCorrectAnswers +
                                                                          numberOfIncorrectAnswers)), null));
            }

            var score = _objectUnderTest.CalculateScore(questionResult);

            Assert.AreEqual(expectedScore, score);
        }
Exemple #3
0
 public Highscore(string username, Guid dictionaryId, QuestionResult questionResult)
 {
     Username         = username;
     QuestionResult   = questionResult;
     QuestionResultId = questionResult.Id;
     DictionaryId     = dictionaryId;
 }
 public void AddQuestionResult(QuestionResult questionResult)
 {
     _chineseCharacterTrainerService.AddQuestionResult(questionResult);
     foreach (var answer in questionResult.Answers)
     {
         _chineseCharacterTrainerService.AddAnswer(answer);
     }
 }
        public void ShouldAddQuestionResultToContextWhenAdding()
        {
            var questionResult = new QuestionResult();

            _objectUnderTest.AddQuestionResult(questionResult);

            _chineseTrainerContextMock.Verify(p => p.Add(questionResult));
        }
        public void ShouldAddQuestionResultAndAnswersWhenAddingQuestionResult()
        {
            var questionResult = new QuestionResult();
            var answer = new Answer(true, DateTime.Now, TimeSpan.FromSeconds(1), null);
            questionResult.AddAnswer(answer);

            _objectUnderTest.AddQuestionResult(questionResult);

            _serviceMock.Verify(p => p.AddQuestionResult(questionResult));
            _serviceMock.Verify(p => p.AddAnswer(answer));
        }
        public void ShouldInitializeSummaryViewModelWhenQuestionsAreFinished()
        {
            var selectedDictionary = new Dictionary("Test", null);
            RaiseStartCompetitionEvent();
            _menuVMMock.Setup(p => p.SelectedDictionary).Returns(selectedDictionary);
            var questionResult = new QuestionResult();

            _questionVMMock.Raise(p => p.QuestionsFinished += null, questionResult);

            _competitionSummaryVMMock.Verify(p => p.Initialize(_menuVMMock.Object.SelectedDictionary, questionResult),
                                             Times.Once());
        }
 public void Initialize(Dictionary dictionary, QuestionResult questionResult)
 {
     Initialize(questionResult);
     _dictionary = dictionary;
 }
        public void ShouldSaveChangesWhenAddingQuestionResult()
        {
            var questionResult = new QuestionResult();

            _objectUnderTest.AddQuestionResult(questionResult);

            _chineseTrainerContextMock.Verify(p => p.SaveChanges());
        }
 private static Highscore CreateHighscore(string username, Dictionary dictionary, int seconds)
 {
     var questionResult = new QuestionResult();
     questionResult.AddAnswer(new Answer(true, DateTime.Now, TimeSpan.FromSeconds(seconds), null));
     return new Highscore(username, dictionary.Id, questionResult);
 }
 public void Initialize(List<DictionaryEntry> dictionaryEntries)
 {
     _dictionaryEntryPicker.Initialize(dictionaryEntries);
     _questionResult = new QuestionResult();
     Answer = string.Empty;
     IsInAnswerMode = true;
     GetNextEntry();
 }
 private void RaiseQuestionsFinished(QuestionResult result)
 {
     var handler = QuestionsFinished;
     if (handler != null) handler(result);
 }
 public int CalculateScore(QuestionResult questionResult)
 {
     return (int)questionResult.Duration.TotalSeconds + questionResult.NumberOfIncorrectAnswers * 5;
 }
 public void Initialize(QuestionResult questionResult)
 {
     QuestionResult = questionResult;
 }
 private void QuestionVMQuestionsFinished(QuestionResult questionResult)
 {
     switch (_trainingMode)
     {
         case TrainingMode.Competition:
             _competitionSummaryVM.Initialize(_menuVM.SelectedDictionary, questionResult);
             Content = _competitionSummaryVM;
             break;
         case TrainingMode.Practice:
             _practiceSummaryVM.Initialize(questionResult);
             Content = _practiceSummaryVM;
             break;
     }
 }