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); }
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); }
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); }
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); }