public void CommandsForWithUnknownType()
        {
            var collection = new LocalCommandCollection();
            var id         = CommandId.Create(typeof(int).GetMethod("CompareTo", new[] { typeof(object) }));

            Assert.Throws <UnknownCommandException>(() => collection.CommandToInvoke(id));
        }
        public void Register()
        {
            var collection = new LocalCommandCollection();

            var map = new[]
            {
                new CommandDefinition(
                    CommandId.Create(typeof(int).GetMethod("CompareTo", new[] { typeof(object) })),
                    new[]
                {
                    new CommandParameterDefinition(typeof(int), "other", CommandParameterOrigin.FromCommand),
                },
                    false,
                    (Action) delegate { }),
            };

            collection.Register(map);

            Assert.IsTrue(collection.Any(id => id == map[0].Id));
        }
        public void CommandsFor()
        {
            var collection = new LocalCommandCollection();

            var map = new[]
            {
                new CommandDefinition(
                    CommandId.Create(typeof(int).GetMethod("CompareTo", new[] { typeof(object) })),
                    new[]
                {
                    new CommandParameterDefinition(typeof(int), "other", CommandParameterOrigin.FromCommand),
                },
                    false,
                    (Action) delegate { }),
            };

            collection.Register(map);

            var commandSet = collection.CommandToInvoke(map[0].Id);

            Assert.AreSame(map[0], commandSet);
        }
        public void RegisterWithExistingType()
        {
            var collection = new LocalCommandCollection();

            var map = new[]
            {
                new CommandDefinition(
                    CommandId.Create(typeof(int).GetMethod("CompareTo", new[] { typeof(object) })),
                    new[]
                {
                    new CommandParameterDefinition(typeof(int), "other", CommandParameterOrigin.FromCommand),
                },
                    false,
                    (Action) delegate { }),
            };

            collection.Register(map);
            Assert.AreEqual(1, collection.Count(id => id == map[0].Id));

            Assert.Throws <CommandAlreadyRegisteredException>(
                () => collection.Register(map));
            Assert.AreEqual(1, collection.Count(id => id == map[0].Id));
        }