public static void AssetThereWasAtleastOneCanExecuteChangedEventAndCommandExecutableStateIs (this CommandObserver commandObserver, bool executableState) { commandObserver.AssetAllSendersWereCorrect(); Assert.AreNotEqual(0, commandObserver.NumberOfEventsRecieved, "No events were recieved"); Assert.AreEqual(executableState, commandObserver.ValueOfCanExecuteOnLatestEvent, "The command is executable"); }
public static CommandObserver GetDelegateCommandObserver(this DelegateCommand command) { CommandObserver observer = new CommandObserver(); observer.ValueOfCanExecuteOnLatestEvent = command.CanExecute(); command.CanExecuteChanged += (obj, e) => { if (command == obj) { observer.WasTheSendersCorrect.Add(true); } observer.ValueOfCanExecuteOnLatestEvent = command.CanExecute(); observer.NumberOfEventsRecieved++; }; return(observer); }
public static void AssertTheCommandBecameNonExecutable(this CommandObserver commandObserver) { commandObserver. AssetThereWasAtleastOneCanExecuteChangedEventAndCommandExecutableStateIs(false); }
public static void AssetAllSendersWereCorrect(this CommandObserver commandObserver) { Assert.AreEqual(0, commandObserver.WasTheSendersCorrect.Count(x => false), "There was atleast one sender for this command that not correct"); }