Пример #1
0
        public void MergeFromFile()
        {
            var lines = new[] {
                "CHAT Test {type=a,stage=b}",
                "SAY Find",
                "FIND {type=a,stage=b,other=c}",
                "CHAT next {type=a,stage=b}",
                "SAY Done",
            };

            ChatRuntime rt;

            rt = new ChatRuntime(Client.AppConfig.TAC);
            rt.ParseText(String.Join("\n", lines));

            var s = rt.InvokeImmediate(null);

            Assert.That(s, Is.EqualTo("Find\nDone"));


            // Add more chats via Update, with higher search score
            var lines2 = new[] {
                "CHAT switch {type=a,stage=b,other=c,statelness=}",
                "SAY Added",
            };

            var file = new FileInfo(AppDomain.CurrentDomain.BaseDirectory + Util.EpochMs() + ".ser");

            ChatRuntime rt2 = new ChatRuntime(Client.AppConfig.TAC);

            rt2.ParseText(String.Join("\n", lines2));
            rt2.Save(serializer, file);

            // append the 2nd runtime to the first
            rt.Merge(serializer, file);

            s = rt.InvokeImmediate(null);
            Assert.That(s, Is.EqualTo("Find\nAdded"));
        }
Пример #2
0
        public void MergeFromBytes()
        {
            var lines = new[] {
                "CHAT Test {type=a,stage=b}",
                "SAY Find",
                "FIND {type=a,stage=b,other=c}",
                "CHAT next {type=a,stage=b}",
                "SAY Done",
            };

            ChatRuntime rt;

            rt = new ChatRuntime(Client.AppConfig.TAC);
            rt.ParseText(String.Join("\n", lines));

            var s = rt.InvokeImmediate(null);

            Assert.That(s, Is.EqualTo("Find\nDone"));


            // Add more chats via Update, with higher search score
            var lines2 = new[] {
                "CHAT switch {type=a,stage=b,other=c,statelness=}",
                "SAY Added",
            };

            ChatRuntime rt2 = new ChatRuntime(Client.AppConfig.TAC);

            rt2.ParseText(String.Join("\n", lines2));

            // append the 2nd runtime to the first
            rt.Merge(serializer, serializer.ToBytes(rt2));

            s = rt.InvokeImmediate(null);
            Assert.That(s, Is.EqualTo("Find\nAdded"));
        }