Example #1
0
        void DoAskQuestion()
        {
            string questionText   = "Hi Alice, how are you today?";
            string questionDetail = "Checking up on you today.";

            string[] validResponses = { "Great!", "Not so good." };

            CommittedAnswerV1_0 handler = CommittedAnswer.v1_0(
                _relDID,
                questionText,
                questionDetail,
                validResponses,
                true);

            handlers.addHandler(
                handler,
                (msgName, message) =>
            {
                if ("answer-given".Equals(msgName))
                {
                    App.consolePrintMessage(msgName, message);

                    questionComplete = true;
                }
                else
                {
                    nonHandled(msgName, message);
                }
            }
                );

            handler.ask(context);

            WaitFor(ref questionComplete, "Waiting for Connect.Me to answer the question");
        }
        public void testGetThreadId()
        {
            CommittedAnswerV1_0 testProtocol = CommittedAnswer.v1_0(
                forRelationship,
                questionText,
                questionDetail,
                validResponses,
                requireSignature);

            Assert.IsNotNull(testProtocol.getThreadId());
        }
        public void testConstructor()
        {
            Context             context      = TestHelpers.getContext();
            CommittedAnswerV1_0 testProtocol = CommittedAnswer.v1_0(
                forRelationship,
                questionText,
                questionDetail,
                validResponses,
                requireSignature
                );
            JsonObject msg = testProtocol.askMsg(context);

            testAskMessages(msg);
        }
        public void testGetMessageType()
        {
            CommittedAnswerV1_0 testProtocol = CommittedAnswer.v1_0(
                forRelationship,
                questionText,
                questionDetail,
                validResponses,
                requireSignature);

            string msgName = "msg name";
            string msgType = Util.getMessageType(
                Util.COMMUNITY_MSG_QUALIFIER,
                testProtocol.family(),
                testProtocol.version(),
                msgName);

            Assert.AreEqual(msgType, testProtocol.messageType(msgName));
        }
        public void testAsk()
        {
            withContext(context => {
                CommittedAnswerV1_0 testProtocol = CommittedAnswer.v1_0(
                    forRelationship,
                    questionText,
                    questionDetail,
                    validResponses,
                    requireSignature);

                byte[] message             = testProtocol.askMsgPacked(context);
                JsonObject unpackedMessage = TestHelpers.unpackForwardMessage(context, message);
                testBaseMessage(unpackedMessage);
                Assert.AreEqual(
                    Util.COMMUNITY_MSG_QUALIFIER + "/committedanswer/1.0/ask-question",
                    unpackedMessage.getAsString("@type")
                    );
            });
        }