Exemplo n.º 1
0
        public void Method_DCEventHandler()
        {
            // arrange
            string id        = "keyDCEventHandler";
            bool   isAnswer  = default(bool);
            string name      = "name";
            var    argValues = new Dictionary <int, object>()
            {
                { 0, "value1" }, { 1, "value2" }
            };

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

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

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

            // assert
            Assert.IsTrue(isAnswer);
            Assert.AreEqual(id, answer.AnswerKey);
            Assert.IsNotNull(answer.ArgValues);
            Assert.AreEqual("value1", answer.ArgValues[0]);
            Assert.AreEqual("value2", answer.ArgValues[1]);
        }
Exemplo n.º 2
0
        public void Method_GetAnswerData()
        {
            // arrange
            AnswerInfo answer   = default(AnswerInfo);
            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();

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

            // assert
            Assert.IsTrue(isAnswer);
            Assert.AreEqual(id, answer.AnswerKey);
        }
Exemplo n.º 3
0
        //10 sec act test
        public async void ProcessedQuery_WithLongAct()
        {
            // arrange
            string id   = "key";
            string name = "name";
            bool   isQuery;
            var    queryHelper  = new QueryHelper();
            var    answerHelper = new AnswerHelper();

            Core.LogChange += CQG_LogChange;
            UnitTestHelper.StartUp();

            // act
            var query = Core.CreateQuery(QueryType.CallCtor, id, string.Empty, name, string.Empty);
            await queryHelper.PushQueryAsync(query);

            isQuery = await UnitTestHelper.QueryHandler.CheckQueryAsync(id);

            // assert 1
            Assert.IsTrue(isQuery);

            UnitTestHelper.QueryHandler.ProcessQuery(query);

            //Waight some time after procssed query
            Task.Delay(10000).GetAwaiter().GetResult();

            Task.Run(async() =>
            {
                isQuery = await UnitTestHelper.QueryHandler.CheckQueryAsync(id);

                // assert 2
                Assert.IsFalse(isQuery);
            }).GetAwaiter().GetResult();

            var answer = answerHelper.GetAnswerData(id);

            // assert 3
            Assert.IsNotNull(answer);
            Assert.AreEqual(id, answer.AnswerKey);
        }