示例#1
0
        public void TestTemplateLifeCycleWithNoEventHandlers()
        {
            this.OnLoadCalled   = false;
            this.OnUnloadCalled = false;
            AimlBot.Request           r = new AimlBot.Request();
            AimlBot.Generate.Template t = new AimlBot.Generate.Template();

            // lets run through the whole life cycle
            t.Init("this is a template");
            t.Load(r);
            Assert.AreEqual(false, this.OnLoadCalled);
            Assert.AreEqual(string.Empty, t.Render());
            t.Unload();
            Assert.AreEqual(false, this.OnUnloadCalled);
        }
示例#2
0
        public void TestTemplateAsParentObject()
        {
            this.OnLoadCalled   = false;
            this.OnUnloadCalled = false;
            AimlBot.Request r  = new AimlBot.Request();
            MockTemplate    mt = new MockTemplate();

            mt.OnLoad   += new EventHandler <EventArgs>(mt_OnLoad);
            mt.OnUnload += new EventHandler <EventArgs>(mt_OnUnload);

            // lets run through the whole life cycle
            mt.Init("Hello, $NAME$!");
            mt.Load(r);
            Assert.AreEqual(true, this.OnLoadCalled);
            Assert.AreEqual("World", mt.Name);
            Assert.AreEqual("Hello, World!", mt.Render());
            mt.Unload();
            Assert.AreEqual(true, this.OnUnloadCalled);
            Assert.AreEqual(string.Empty, mt.Name);
        }
示例#3
0
        public void TestTemplateLifeCycleWithEventHandlers()
        {
            this.OnLoadCalled = false;
            this.OnUnloadCalled = false;
            AimlBot.Request r = new AimlBot.Request();
            AimlBot.Generate.Template t = new AimlBot.Generate.Template();
            t.OnLoad += new EventHandler<EventArgs>(t_OnLoad);
            t.OnUnload += new EventHandler<EventArgs>(t_OnUnload);

            // lets run through the whole life cycle
            t.Init("this is a template");
            t.Load(r);
            Assert.AreEqual(true, this.OnLoadCalled);
            Assert.AreEqual(string.Empty, t.Render());
            t.Unload();
            Assert.AreEqual(true, this.OnUnloadCalled);
        }
示例#4
0
        public void TestTemplateAsParentObject()
        {
            this.OnLoadCalled = false;
            this.OnUnloadCalled = false;
            AimlBot.Request r = new AimlBot.Request();
            MockTemplate mt = new MockTemplate();
            mt.OnLoad += new EventHandler<EventArgs>(mt_OnLoad);
            mt.OnUnload += new EventHandler<EventArgs>(mt_OnUnload);

            // lets run through the whole life cycle
            mt.Init("Hello, $NAME$!");
            mt.Load(r);
            Assert.AreEqual(true, this.OnLoadCalled);
            Assert.AreEqual("World", mt.Name);
            Assert.AreEqual("Hello, World!", mt.Render());
            mt.Unload();
            Assert.AreEqual(true, this.OnUnloadCalled);
            Assert.AreEqual(string.Empty, mt.Name);
        }