Beispiel #1
0
        public void ShouldDoStuffWhenCommandExecutes()
        {
            var command = Substitute.For <ICommand>();
            var watcher = new CommandWatcher(command);

            command.Executed += Raise.Event();

            Assert.That(watcher.DidStuff);
        }
Beispiel #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>();
        }