Exemple #1
0
        public async Task UndoAnswerThrowsExceptionOnCancelled()
        {
            var server = await m_serverLocator.SearchAsync(Language.English, ServerType.Person).ConfigureAwait(false);

            using (IAkinatorClient client = new AkinatorClient(server))
            {
                var src = new CancellationTokenSource();
                var cancellationToken = src.Token;
                src.Cancel();

                await client.UndoAnswer(cancellationToken);
            }

            Assert.Fail("No exception was thrown");
        }
Exemple #2
0
        public async Task CurrentQuestionReturnsCurrentQuestion()
        {
            var server = await m_serverLocator.SearchAsync(Language.English, ServerType.Person).ConfigureAwait(false);

            using IAkinatorClient client = new AkinatorClient(server);

            var questionStart = await client.StartNewGame();

            Assert.AreEqual(questionStart.Text, client.CurrentQuestion.Text);

            questionStart = await client.Answer(AnswerOptions.Yes);

            Assert.AreEqual(questionStart.Text, client.CurrentQuestion.Text);

            questionStart = await client.Answer(AnswerOptions.Yes);

            Assert.AreEqual(questionStart.Text, client.CurrentQuestion.Text);

            questionStart = await client.UndoAnswer();

            Assert.AreEqual(questionStart.Text, client.CurrentQuestion.Text);
        }
Exemple #3
0
        public async Task UndoWorksAsExpected()
        {
            var server = await m_serverLocator.SearchAsync(Language.English, ServerType.Person).ConfigureAwait(false);

            using IAkinatorClient client = new AkinatorClient(server);

            var questionStart = await client.StartNewGame();

            Assert.AreEqual(0, questionStart.Step);

            var question1 = await client.Answer(AnswerOptions.Yes);

            Assert.AreEqual(1, question1.Step);

            var question2 = await client.Answer(AnswerOptions.Yes);

            Assert.AreEqual(2, question2.Step);

            var questionPrevious = await client.UndoAnswer();

            Assert.AreEqual(1, questionPrevious.Step);
            Assert.AreEqual(question1.Text, questionPrevious.Text);
        }