Пример #1
0
        public void ShouldDoStuffWhenCommandExecutes()
        {
            var command = Substitute.For <ICommand>();
            var watcher = new CommandWatcher(command);

            command.Executed += Raise.Event();

            Assert.That(watcher.DidStuff);
        }
Пример #2
0
        public void MakeSureWatcherSubscribesToCommandExecuted()
        {
            var command = Substitute.For <ICommand>();
            var watcher = new CommandWatcher(command);

            // Not recommended. Favour testing behaviour over implementation specifics.
            // Can check subscription:
            command.Received().Executed += watcher.OnExecuted;
            // Or, if the handler is not accessible:
            command.Received().Executed += Arg.Any <EventHandler>();
        }