コード例 #1
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);
        }
コード例 #2
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);
        }
コード例 #3
0
        public void InvokeWithoutContextWithUnknownName()
        {
            var factory = new CommandFactory();

            Assert.Throws <UnknownCommandException>(() => factory.Invoke(new CommandId("name")));
        }
コード例 #4
0
 public void InvokeWithoutContextWithUnknownName()
 {
     var factory = new CommandFactory();
     Assert.Throws<UnknownCommandException>(() => factory.Invoke(new CommandId("name")));
 }