示例#1
0
        public void AddWithDuplicateName()
        {
            var factory = new CommandFactory();

            var             name      = new CommandId("name");
            Func <ICommand> activator = () => new Mock <ICommand>().Object;

            factory.Add(name, activator);
            Assert.Throws <DuplicateCommandException>(() => factory.Add(name, activator));
        }
示例#2
0
        public void AddWithDuplicateName()
        {
            var factory = new CommandFactory();

            var name = new CommandId("name");
            Func<ICommand> activator = () => new Mock<ICommand>().Object;

            factory.Add(name, activator);
            Assert.Throws<DuplicateCommandException>(() => factory.Add(name, activator));
        }
示例#3
0
        public void Add()
        {
            var factory = new CommandFactory();

            var             name      = new CommandId("name");
            Func <ICommand> activator = () => new Mock <ICommand>().Object;

            factory.Add(name, activator);
            Assert.IsTrue(factory.Contains(name));
        }
示例#4
0
        public void Add()
        {
            var factory = new CommandFactory();

            var name = new CommandId("name");
            Func<ICommand> activator = () => new Mock<ICommand>().Object;

            factory.Add(name, activator);
            Assert.IsTrue(factory.Contains(name));
        }
示例#5
0
        public void InvokeWithoutContext()
        {
            var factory = new CommandFactory();
            var name = new CommandId("name");

            ICommandContext storedContext = null;
            var commandMock = new Mock<ICommand>();
            {
                commandMock.Setup(command => command.Invoke(It.IsAny<ICommandContext>()))
                    .Callback<ICommandContext>(context => { storedContext = context; });
            }

            factory.Add(name, () => commandMock.Object);
            factory.Invoke(name);
            Assert.IsNotNull(storedContext);
        }
示例#6
0
        public void InvokeWithoutContext()
        {
            var factory = new CommandFactory();
            var name    = new CommandId("name");

            ICommandContext storedContext = null;
            var             commandMock   = new Mock <ICommand>();

            {
                commandMock.Setup(command => command.Invoke(It.IsAny <ICommandContext>()))
                .Callback <ICommandContext>(context => { storedContext = context; });
            }

            factory.Add(name, () => commandMock.Object);
            factory.Invoke(name);
            Assert.IsNotNull(storedContext);
        }