Esempio n. 1
0
        public void SharpScript_works_with_code()
        {
            SharpScript            script  = new SharpScript("test", _codeAll);
            IEnumerable <IElement> result  = script.OnElement(_maction.Object, _melement.Object);
            IEnumerable <IElement> result2 = script.OnCompleted(_maction.Object);

            Assert.IsNotNull(result);
            Assert.IsNotNull(result2);
            Assert.AreEqual(1, result.Count());
            Assert.AreEqual(1, result2.Count());
        }
Esempio n. 2
0
        public void SharpScript_works_with_only_OnCompleted()
        {
            SharpScript            script  = new SharpScript("test", _codeOnCompleted);
            IEnumerable <IElement> result  = script.OnElement(_maction.Object, _melement.Object);
            IEnumerable <IElement> result2 = script.OnCompleted(_maction.Object);

            Assert.IsNotNull(result);
            Assert.IsNotNull(result2);
            Assert.AreEqual(0, result.Count());
            Assert.AreEqual(1, result2.Count());
            var elem = result2.First();

            Assert.AreEqual("testaction", elem.Name);
            Assert.AreEqual("0", elem.Id);
        }
Esempio n. 3
0
        public void SharpScript_works_with_functions()
        {
            bool        onelement   = false;
            bool        oncompleted = false;
            bool        onerror     = false;
            bool        onfinally   = false;
            SharpScript script      = new SharpScript("test", (a, e) => { onelement = true; return(null); }, a => { oncompleted = true; return(null); },
                                                      (a, ex) => { onerror = true; return(null); }, a => { onfinally = true; });
            IEnumerable <IElement> result  = script.OnElement(_maction.Object, _melement.Object);
            IEnumerable <IElement> result2 = script.OnCompleted(_maction.Object);
            IEnumerable <IElement> result3 = script.OnError(_maction.Object, new Exception());

            script.OnFinally(_maction.Object);
            Assert.IsTrue(onelement);
            Assert.IsTrue(oncompleted);
            Assert.IsTrue(onerror);
            Assert.IsTrue(onfinally);
            Assert.IsNotNull(result);
            Assert.IsNotNull(result2);
            Assert.IsNotNull(result3);
            Assert.AreEqual(0, result.Count());
            Assert.AreEqual(0, result2.Count());
            Assert.AreEqual(0, result3.Count());
        }