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"); }
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); }
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); }