public void CanVerifyWhenIsBoundToInstanceMethodsOnAnotherObject() { var other = new SimpleCommandCanBeVerifiedWithoutCallingIt(); _testSubject = new SimpleCommand(other._CorrectCanExecuteInstanceMethod, other._CorrectExecuteInstanceMethod); Assert.That(_testSubject.MethodHandlingCanExecute, Calls.To(() => other._CorrectCanExecuteInstanceMethod())); Assert.That(_testSubject.MethodHandlingExecute, Calls.To(() => other._CorrectExecuteInstanceMethod())); }
public void ShouldFireAssertionWhenBindingIsNotAsExpected() { var other = new SimpleCommandCanBeVerifiedWithoutCallingIt(); _testSubject = new SimpleCommand(_CorrectCanExecuteInstanceMethod, other._CorrectExecuteInstanceMethod); var actualBinding = Extract.BindingInfoFrom(() => other._CorrectExecuteInstanceMethod()).ToString(); _AssertionShouldFail(() => _CorrectExecuteStaticMethod(), "bound to incorrect method", actualBinding); _AssertionShouldFail(() => _CorrectExecuteInstanceMethod(), "bound to incorrect object instance", actualBinding); }
public AllGameSystemsViewModel([NotNull] params GameSystem[] gameSystems) { _allGameSystems = gameSystems; _characterOpener = new CharacterFileInteraction(_allGameSystems, true, _HaveGameSystemLoadChar); _createNewCharacter = new CharacterFileInteraction(_allGameSystems.Where(g => !g.IsReadOnly), false, _HaveGameSystemCreateChar); _currentCharacter = new TrackingNullableProperty<Character>(this, () => Character, () => IsValid, () => CharFileName); OpenCharCommand = new SimpleCommand(Always.Enabled, SwitchCharacter); CreateCharCommand = new SimpleCommand(_HasAtLeastOneWritableGameSystem, CreateNewCharacter); }
public void CanVerifyWhenIsBoundToStaticMethods() { _testSubject = new SimpleCommand(_CorrectCanExecuteStaticMethod, _CorrectExecuteStaticMethod); Assert.That(_testSubject.MethodHandlingCanExecute, Calls.To(() => _CorrectCanExecuteStaticMethod())); Assert.That(_testSubject.MethodHandlingExecute, Calls.To(() => _CorrectExecuteStaticMethod())); }
public void CanVerifyEntireCommandAtOnce() { _testSubject = new SimpleCommand(_CorrectCanExecuteInstanceMethod, _CorrectExecuteInstanceMethod); Assert.That(_testSubject, Command.DelegatesTo(() => _CorrectCanExecuteInstanceMethod(), () => _CorrectExecuteInstanceMethod())); }