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); }
public void Initialize() { _questionResult = new QuestionResult(); _questionResult.AddAnswer(new Answer(true, DateTime.Now, TimeSpan.FromSeconds(1), null)); _questionResult.AddAnswer(new Answer(false, DateTime.Now, TimeSpan.FromSeconds(1), null)); _questionResult.AddAnswer(new Answer(false, DateTime.Now, TimeSpan.FromSeconds(1), null)); _repositoryMock = new Mock <IRepository>(); _scoreCalculatorMock = new Mock <IScoreCalculator>(); _objectUnderTest = new CompetitionSummaryVM(_repositoryMock.Object, _scoreCalculatorMock.Object); _objectUnderTest.Initialize(_dictionary, _questionResult); }
private static Highscore CreateHighscore(Dictionary dictionary1) { var questionResult = new QuestionResult(); questionResult.AddAnswer(new Answer(true, DateTime.Now, TimeSpan.FromSeconds(1), dictionary1.Entries[0])); return(new Highscore("Frank", dictionary1.Id, questionResult)); }
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 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)); }
private void AddAnswer(bool isCorrect) { _questionResult.AddAnswer(new Answer(isCorrect, _dateTime.Now, _dateTime.Now - _startTime, CurrentEntry)); RaisePropertyChanged(() => NumberOfCorrectAnswers); RaisePropertyChanged(() => NumberOfIncorrectAnswers); }