示例#1
0
        public void SaveRestoreChats()
        {
            ChatRuntime rtOut, rtIn;

            var testfile = AppDomain.CurrentDomain.BaseDirectory;

            testfile += "../../../../dialogic/data/noglobal.gs";

            rtIn = new ChatRuntime(Client.AppConfig.TAC);
            rtIn.ParseFile(new FileInfo(testfile));

            var bytes = serializer.ToBytes(rtIn);

            rtOut = ChatRuntime.Create(serializer, bytes, AppConfig.TAC);

            // check they are identical
            Assert.That(rtIn, Is.EqualTo(rtOut));

            var inCmds  = rtIn.Chats();
            var outCmds = rtOut.Chats();

            Assert.That(rtOut.ToString(), Is.EqualTo(rtIn.ToString()));

            Assert.That(inCmds.Count, Is.EqualTo(outCmds.Count));
            for (int i = 0; i < inCmds.Count; i++)
            {
                var chat1 = inCmds.ElementAt(i);
                var chat2 = outCmds.ElementAt(i);
                Assert.That(chat1.text, Is.EqualTo(chat2.text));
                Assert.That(chat1.commands.Count, Is.EqualTo(chat2.commands.Count));
                Assert.That(chat1.ToTree(), Is.EqualTo(chat2.ToTree()));
            }
        }