예제 #1
0
        public void TestExecute()
        {
            int i    = 0;
            var repo = new ActionRepository();

            repo.AddAction("add", s => i++);
            repo.AddAction("add2", s => i++, s => true);
            repo.Execute("add", null);
            Assert.AreEqual(1, i);
            repo.Execute("add2", null);
            Assert.AreEqual(2, i);
        }
예제 #2
0
        public void TestReleaseExecute()
        {
            int i       = 0;
            var repo    = new ActionRepository();
            var release = repo.AddAction("a", s => i++);

            Assert.IsTrue(repo.Contains("a"));
            repo.Execute("a", null);
            Assert.AreEqual(1, i);
            release.Release();
            Assert.IsFalse(repo.Contains("a"));
            repo.Execute("a", null);
            Assert.AreEqual(1, i);
        }
예제 #3
0
        public void TestAddMultiTimes()
        {
            int a    = 0;
            int b    = 0;
            var repo = new ActionRepository();

            repo.AddAction("add", s => a++);
            repo.AddAction("add", s => b++, s => true);
            repo.Execute("add", null);
            Assert.AreEqual(0, a);
            Assert.AreEqual(1, b);
        }
예제 #4
0
        public void TestAddNull()
        {
            var repo = new ActionRepository();

            try
            {
                repo.AddAction("Hello", null);
                Assert.Fail();
            }
            catch (ArgumentNullException) { }

            Assert.IsFalse(repo.Contains("Hello"));
            repo.Execute("Hello", null);
        }