public void TestCanExecute() { var repo = new ActionRepository(); repo.AddAction("true", s => { }, s => true); repo.AddAction("false", s => { }, s => false); Assert.IsTrue(repo.CanExecute("true", null)); Assert.IsFalse(repo.CanExecute("false", null)); Assert.IsFalse(repo.CanExecute("notExisting", null)); }
public void TestReleaseActionCanExecute() { int i = 0; var repo = new ActionRepository(); var release = repo.AddAction("a", s => i++, s => true); Assert.IsTrue(repo.Contains("a")); repo.Execute("a", null); Assert.AreEqual(1, i); Assert.IsTrue(repo.CanExecute("a", null)); release.Release(); Assert.IsFalse(repo.Contains("a")); repo.Execute("a", null); Assert.AreEqual(1, i); Assert.IsFalse(repo.CanExecute("a", null)); }