Exemplo n.º 1
0
        public void ConversationalDataSpanBahaviorTest()
        {
            f.InitWorkSpace();
            ConversationalData <int> single     = new ConversationalData <int>(ConversationalDataMode.Normal, 1);
            ConversationalData <int> singleTemp =
                new ConversationalData <int>(ConversationalDataMode.OutOfConversationSafe, 1);

            f.CurrentConversation.SpanWithPostBacks();
            Guid cid1 = f.CurrentConversation.Id;

            f.CloseWorkSpace();
            f.InitWorkSpace();
            ExpectConversationUnavailableException(single);
            Assert.AreEqual(0, singleTemp.Value);
            f.CloseWorkSpace();
            f.InitWorkSpace();
            ExpectConversationUnavailableException(single);
            Assert.AreEqual(0, singleTemp.Value);
            singleTemp.Value = 2;
            f.CurrentConversation.SpanWithPostBacks();
            Guid cid2 = f.CurrentConversation.Id;

            Assert.AreNotEqual(cid2, cid1);
            f.CloseWorkSpace();
            f.InitWorkSpace(cid1);
            Assert.AreEqual(1, single.Value);
            Assert.AreEqual(0, singleTemp.Value);
            f.CurrentConversation.FinishSpan();
            f.CloseWorkSpace();
            f.InitWorkSpace(cid2);
            ExpectConversationUnavailableException(single);
            Assert.AreEqual(0, singleTemp.Value);
            f.CurrentConversation.FinishSpan();
            f.CloseWorkSpace();
        }
Exemplo n.º 2
0
    public void InitializeQuestionAnswer(ConversationalData data)
    {
        AnswerQuestionPanel.Instance.ClearAnswers();

        AnswerQuestionPanel.Instance.ChangeQuestion(data.question);
        nextDataToSend          = new ConversationalData();
        nextDataToSend.cardType = NetworkController.Instance.GameType;
        var answers = new List <AnswerInfo>();

        for (int i = 0; i < data.answers.Length; i++)
        {
            string             possibleNewId = data.answers[i] + data.question;
            ConversationalData newData       = new ConversationalData {
                cardType = NetworkController.Instance.GameType, question = "whateve", _id = possibleNewId
            };
            answers.Add(new AnswerInfo
            {
                name    = data.answers[i],
                onClick = () =>
                {
                    this.nextDataToSend._id = newData._id;
                    NetworkController.Instance.SendWebSocketMessage(8, JsonUtility.ToJson(newData));
                }
            });
        }

        AnswerQuestionPanel.Instance.ShowAnswers(answers);
    }
        public void ConversationalDataSpanBahaviorTest()
        {
            f.InitWorkSpace();
            ConversationalData<int> single = new ConversationalData<int>(ConversationalDataMode.Normal, 1);
            ConversationalData<int> singleTemp =
                new ConversationalData<int>(ConversationalDataMode.OutOfConversationSafe, 1);

            f.CurrentConversation.SpanWithPostBacks();
            Guid cid1 = f.CurrentConversation.Id;

            f.CloseWorkSpace();
            f.InitWorkSpace();
            ExpectConversationUnavailableException(single);
            Assert.AreEqual(0, singleTemp.Value);
            f.CloseWorkSpace();
            f.InitWorkSpace();
            ExpectConversationUnavailableException(single);
            Assert.AreEqual(0, singleTemp.Value);
            singleTemp.Value = 2;
            f.CurrentConversation.SpanWithPostBacks();
            Guid cid2 = f.CurrentConversation.Id;
            Assert.AreNotEqual(cid2, cid1);
            f.CloseWorkSpace();
            f.InitWorkSpace(cid1);
            Assert.AreEqual(1, single.Value);
            Assert.AreEqual(0, singleTemp.Value);
            f.CurrentConversation.FinishSpan();
            f.CloseWorkSpace();
            f.InitWorkSpace(cid2);
            ExpectConversationUnavailableException(single);
            Assert.AreEqual(0, singleTemp.Value);
            f.CurrentConversation.FinishSpan();
            f.CloseWorkSpace();
        }
Exemplo n.º 4
0
 private void ExpectConversationUnavailableException(ConversationalData <int> c)
 {
     try
     {
         c.Value.ToString();
         Assert.Fail("Failed to throw a ConversationUnavailableException.");
     }
     catch (ConversationUnavailableException) {}
 }
 private void ExpectConversationUnavailableException(ConversationalData<int> c)
 {
     try
     {
         c.Value.ToString();
         Assert.Fail("Failed to throw a ConversationUnavailableException.");
     }
     catch (ConversationUnavailableException) {}
 }
 public object OnSave(object toSave, object objectInStateContainer)
 {
     if (toSave == null)
     {
         return null;
     }
     ConversationalData<object> retVal = objectInStateContainer as ConversationalData<object>;
     if (retVal == null)
     {
         retVal = new ConversationalData<object>();
     }
     retVal.Value = toSave;
     return retVal;
 }
        public object OnSave(object toSave, object objectInStateContainer)
        {
            if (toSave == null)
            {
                return(null);
            }
            ConversationalData <object> retVal = objectInStateContainer as ConversationalData <object>;

            if (retVal == null)
            {
                retVal = new ConversationalData <object>();
            }
            retVal.Value = toSave;
            return(retVal);
        }
        public void ConversationalDataPersistsTest()
        {
            f.InitWorkSpace();
            ConversationalData<int> i = new ConversationalData<int>(ConversationalDataMode.Normal);
            ConversationalData<string> s = new ConversationalData<string>(ConversationalDataMode.Normal, "sometext");
            Assert.AreEqual(0, i.Value);
            Assert.AreEqual("sometext", s.Value);
            i.Value = 1;
            s.Value = null;
            Assert.AreEqual(1, i.Value);
            Assert.IsNull(s.Value);
            f.CurrentConversation.SpanWithPostBacks();
            Guid cid = f.CurrentConversation.Id;

            f.CloseWorkSpace();
            f.InitWorkSpace(cid);

            Assert.AreEqual(1, i.Value);
            Assert.IsNull(s.Value);
            f.CurrentConversation.FinishSpan();
            f.CloseWorkSpace();
        }
Exemplo n.º 9
0
        public void ConversationalDataPersistsTest()
        {
            f.InitWorkSpace();
            ConversationalData <int>    i = new ConversationalData <int>(ConversationalDataMode.Normal);
            ConversationalData <string> s = new ConversationalData <string>(ConversationalDataMode.Normal, "sometext");

            Assert.AreEqual(0, i.Value);
            Assert.AreEqual("sometext", s.Value);
            i.Value = 1;
            s.Value = null;
            Assert.AreEqual(1, i.Value);
            Assert.IsNull(s.Value);
            f.CurrentConversation.SpanWithPostBacks();
            Guid cid = f.CurrentConversation.Id;

            f.CloseWorkSpace();
            f.InitWorkSpace(cid);

            Assert.AreEqual(1, i.Value);
            Assert.IsNull(s.Value);
            f.CurrentConversation.FinishSpan();
            f.CloseWorkSpace();
        }
Exemplo n.º 10
0
        public void SpanOverMultipleDomainContextTest()
        {
            f.InitWorkSpace();
            f.CurrentConversation.SpanWithPostBacks();
            ConversationalData <int>    i = new ConversationalData <int>(ConversationalDataMode.Normal);
            ConversationalData <string> s = new ConversationalData <string>(ConversationalDataMode.Normal, "sometext");
            Guid gid = f.CurrentConversation.Id;

            i.Value = 1;
            f.CloseWorkSpace();
            f.InitWorkSpace();
            try
            {
                i.Value.ToString();
                Assert.Fail("Failed to throw a ConversationUnavailableException.");
            }
            catch (ConversationUnavailableException) {}
            f.CloseWorkSpace();
            f.InitWorkSpace(gid);
            Assert.AreEqual(1, i.Value);
            Assert.AreEqual("sometext", s.Value);
            f.CurrentConversation.FinishSpan();
            f.CloseWorkSpace();
        }
 public void SpanOverMultipleDomainContextTest()
 {
     f.InitWorkSpace();
     f.CurrentConversation.SpanWithPostBacks();
     ConversationalData<int> i = new ConversationalData<int>(ConversationalDataMode.Normal);
     ConversationalData<string> s = new ConversationalData<string>(ConversationalDataMode.Normal, "sometext");
     Guid gid = f.CurrentConversation.Id;
     i.Value = 1;
     f.CloseWorkSpace();
     f.InitWorkSpace();
     try
     {
         i.Value.ToString();
         Assert.Fail("Failed to throw a ConversationUnavailableException.");
     }
     catch (ConversationUnavailableException) {}
     f.CloseWorkSpace();
     f.InitWorkSpace(gid);
     Assert.AreEqual(1, i.Value);
     Assert.AreEqual("sometext", s.Value);
     f.CurrentConversation.FinishSpan();
     f.CloseWorkSpace();
 }