Exemplo n.º 1
0
        public void MethodAsync_RemoveOneAnswerItem()
        {
            // arrange
            string id       = "key";
            bool   isAnswer = default(bool);
            string name     = "name";

            Core.LogChange += CQG_LogChange_Mock;
            var answerHelper = new AnswerHelper();

            UnitTestHelper.StartUp();
            Task.Run(async() =>
            {
                await answerHelper.ClearAnswersListAsync();
            }).GetAwaiter().GetResult();

            Task.Run(async() =>
            {
                // act
                await AnswerHandler.PushAnswerAsync(new AnswerInfo(id, string.Empty, name, null, null));
                isAnswer = await answerHelper.CheckAnswerAsync(id);
                await answerHelper.RemoveAnswerAsync(id);
                isAnswer = await answerHelper.CheckAnswerAsync(id);
            }).GetAwaiter().GetResult();

            // assert
            Assert.AreEqual(isAnswer, false);
        }
Exemplo n.º 2
0
        public void MethodAsync_PushOneAnswerItem()
        {
            // arrange
            string idTrue   = "keyTrue";
            string idFalse  = "keyFalse";
            string name     = "name";
            bool   isAnswer = default(bool);

            Core.LogChange += CQG_LogChange_Mock;
            var answerHelper = new AnswerHelper();

            Task.Run(async() =>
            {
                await answerHelper.ClearAnswersListAsync();
            }).GetAwaiter().GetResult();
            Task.Run(async() =>
            {
                // act 1
                await AnswerHandler.PushAnswerAsync(new AnswerInfo(idTrue, string.Empty, name, null, null));
                isAnswer = await answerHelper.CheckAnswerAsync(idTrue);

                // assert 1
                Assert.AreEqual(isAnswer, true);

                // act 2
                isAnswer = await answerHelper.CheckAnswerAsync(idFalse);

                // assert 2
                Assert.AreEqual(isAnswer, false);
            }).GetAwaiter().GetResult();
        }