public void Should_fail_to_add_answer_to_non_existing_question() { var session = TestSession.CreateNew(_user, _quiz, _timeProvider); Action answer = () => session.Answer(10, "PANIC"); answer.Should().Throw <TaskNumberOutOfRangeException>(); }
public void Should_set_to_finished_on_finish() { var session = TestSession.CreateNew(_user, _quiz, _timeProvider); session.Finish(); session.IsFinished.Should().BeTrue(); }
public void Should_start_new_session() { var session = TestSession.CreateNew(_user, _quiz, _timeProvider); session.Started.Should().Be(_startTime); session.Answers.Count.Should().Be(_quiz.Tasks.Count); session.IsFinished.Should().BeFalse(); session.Quiz.Should().Be(_quiz); }
public void Should_set_test_result_on_finish() { var session = TestSession.CreateNew(_user, _quiz, _timeProvider); session.Answer(0, "bar"); session.Finish(); session.Result.Should().Be(2); }
public void Should_fail_to_answer_if_time_is_over() { var session = TestSession.CreateNew(_user, _quiz, _timeProvider); var checkTime = new DateTime(1971, 01, 01); _timeProvider.GetCurrent().Returns(checkTime); Action answer = () => session.Answer(0, "foo"); answer.Should().Throw <TestSessionAlreadyFinishedException>(); }
public void StartNewSession(Quiz quiz) { if (HasActiveSession()) { throw new AlreadyHasActiveSessionException(); } var session = TestSession.CreateNew( this, quiz); TestSessions.Add(session); }
public void Should_set_session_to_finished_if_answering_after_time_expired() { var session = TestSession.CreateNew(_user, _quiz, _timeProvider); var checkTime = new DateTime(1971, 01, 01); _timeProvider.GetCurrent().Returns(checkTime); session.IsFinished.Should().BeFalse(); try { session.Answer(0, "foo"); } catch (TestSessionAlreadyFinishedException) { } session.IsFinished.Should().BeTrue(); }