public void RemoveTest() { ICommandAggregator cmdAgg = CommandAggregatorFactory.GetNewCommandAggregator(); cmdAgg.AddOrSetCommand("TestCommand1", new RelayCommand(p1 => { }, p2 => true)); cmdAgg.AddOrSetCommand("TestCommand2", new RelayCommand(p1 => { }, p2 => true)); cmdAgg.AddOrSetCommand("TestCommand3", new RelayCommand(p1 => { }, p2 => true)); cmdAgg.AddOrSetCommand("TestCommand4", new RelayCommand(p1 => { }, p2 => true)); cmdAgg.AddOrSetCommand("TestCommand5", new RelayCommand(p1 => { }, p2 => true)); Assert.IsTrue(cmdAgg.Count() == 5); cmdAgg.Remove("TestCommand3"); Assert.IsTrue(cmdAgg.Count() == 4); Assert.IsTrue(cmdAgg.Exists("TestCommand1")); Assert.IsTrue(cmdAgg.Exists("TestCommand2")); Assert.IsFalse(cmdAgg.Exists("TestCommand3")); Assert.IsTrue(cmdAgg.Exists("TestCommand4")); Assert.IsTrue(cmdAgg.Exists("TestCommand5")); cmdAgg.RemoveAll(); Assert.IsTrue(cmdAgg.Count() == 0); Assert.IsFalse(cmdAgg.Exists("TestCommand1")); Assert.IsFalse(cmdAgg.Exists("TestCommand2")); Assert.IsFalse(cmdAgg.Exists("TestCommand3")); Assert.IsFalse(cmdAgg.Exists("TestCommand4")); Assert.IsFalse(cmdAgg.Exists("TestCommand5")); }
public void CollectionConstructionTest() { ICommand cmd1 = new RelayCommand(p1 => { }, p2 => true); ICommand cmd2 = new RelayCommand(p1 => { }, p2 => true); var commandList = new List <KeyValuePair <string, ICommand> >(); commandList.Add(new KeyValuePair <string, ICommand>("A", cmd1)); commandList.Add(new KeyValuePair <string, ICommand>("B", cmd2)); ICommandAggregator cmdAgg = CommandAggregatorFactory.GetNewCommandAggregator(commandList); Assert.IsTrue(cmdAgg.Exists("A")); Assert.IsTrue(cmdAgg.Exists("B")); Assert.IsTrue(cmdAgg.Count() == 2); }
public void AddAndExistsTest() { ICommandAggregator cmdAgg = CommandAggregatorFactory.GetNewCommandAggregator(); cmdAgg.AddOrSetCommand("TestCommand1", new RelayCommand(p1 => { }, p2 => true)); cmdAgg.AddOrSetCommand("TestCommand2", new RelayCommand(p1 => { }, p2 => true)); Action <object> act = new Action <object>(p0 => { }); Predicate <object> pred = new Predicate <object>(p1 => { return(true); }); cmdAgg.AddOrSetCommand("TestCommand3", act, pred); Assert.IsTrue(cmdAgg.Exists("TestCommand1")); Assert.IsTrue(cmdAgg.Exists("TestCommand2")); Assert.IsTrue(cmdAgg.Exists("TestCommand3")); Assert.IsFalse(cmdAgg.Exists("TestCommand4")); }