Exemplo n.º 1
0
        public void TestFsaNodeAddChildNotRootNode()
        {
            AimlBot.Normalize.Utils.FsaNode fsagraph = new AimlBot.Normalize.Utils.FsaNode(0);
            AimlBot.Normalize.Utils.FsaNode leaf1    = fsagraph.Add("abc", "xyz");

            string    msg = string.Empty;
            Exception e   = null;

            try
            {
                AimlBot.Normalize.Utils.FsaNode badNode = leaf1.Add("adc", "xyz");
            }
            catch (Exception ex)
            {
                e   = ex;
                msg = ex.Message;
            }
            Assert.AreEqual(true, (e is AimlBot.Normalize.NormalizationException));
            Assert.AreEqual(true, msg.Length > 0);
            rm = new System.Resources.ResourceManager("AimlBot.Normalize.Utils.FsaNodeResources", System.Reflection.Assembly.GetAssembly(leaf1.GetType()));

            Assert.AreEqual(String.Format(rm.GetString("NotRootNode"), "3"), msg);
        }
Exemplo n.º 2
0
        public void TestFsaNodeAddChildOverriddenByExistingMatch()
        {
            AimlBot.Normalize.Utils.FsaNode fsagraph = new AimlBot.Normalize.Utils.FsaNode(0);
            AimlBot.Normalize.Utils.FsaNode leaf1    = fsagraph.Add("abc", "xyz");
            string    msg = string.Empty;
            Exception e   = null;

            try
            {
                AimlBot.Normalize.Utils.FsaNode leaf2 = fsagraph.Add("abcdefg", "tuvwxyz");
            }
            catch (Exception ex)
            {
                e   = ex;
                msg = ex.Message;
            }
            Assert.AreEqual(true, (e is AimlBot.Normalize.NormalizationException));
            rm = new System.Resources.ResourceManager("AimlBot.Normalize.Utils.FsaNodeResources", System.Reflection.Assembly.GetAssembly(leaf1.GetType()));
            Assert.AreEqual(String.Format(rm.GetString("DuplicateSubstitution"), "abcdefg", "tuvwxyz", "abc", "xyz"), msg);
        }